View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.access.joran.action;
11  
12  import org.xml.sax.Attributes;
13  
14  import ch.qos.logback.core.joran.action.Action;
15  import ch.qos.logback.core.joran.spi.InterpretationContext;
16  import ch.qos.logback.core.util.StatusPrinter;
17  
18  
19  
20  public class ConfigurationAction extends Action {
21    static final String INTERNAL_DEBUG_ATTR = "debug";
22    boolean debugMode = false;
23  
24    public void begin(InterpretationContext ec, String name, Attributes attributes) {
25      String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
26  
27      if (
28        (debugAttrib == null) || debugAttrib.equals("")
29          || debugAttrib.equals("false") || debugAttrib.equals("null")) {
30        addInfo("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
31      } else { 
32        debugMode = true;
33      }
34  
35      // the context is appender attachable, so it is pushed on top of the stack
36      ec.pushObject(getContext());
37    }
38  
39    public void end(InterpretationContext ec, String name) {
40      addInfo("End of configuration.");
41      if (debugMode) {
42        StatusPrinter.print(context);
43      }
44      
45      ec.popObject();
46    }
47  }