View Javadoc

1   /**
2    * LOGBack: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, 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  
11  package ch.qos.logback.classic.joran.action;
12  
13  import org.xml.sax.Attributes;
14  
15  import ch.qos.logback.classic.LoggerContext;
16  import ch.qos.logback.core.joran.action.Action;
17  import ch.qos.logback.core.joran.spi.InterpretationContext;
18  import ch.qos.logback.core.util.StatusPrinter;
19  
20  
21  
22  public class ConfigurationAction extends Action {
23    static final String INTERNAL_DEBUG_ATTR = "debug";
24    boolean debugMode = false;
25  
26    public void begin(InterpretationContext ec, String name, Attributes attributes) {
27      String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
28  
29      if (
30        (debugAttrib == null) || debugAttrib.equals("")
31          || debugAttrib.equals("false") || debugAttrib.equals("null")) {
32        addInfo(INTERNAL_DEBUG_ATTR + " attribute not set");
33      } else {
34        //LoggerContext loggerContext = (LoggerContext) context;
35        //ConfiguratorBase.attachTemporaryConsoleAppender(context);
36   
37        debugMode = true;
38      }
39      
40      // the context is turbo filter attachable, so it is pushed on top of the stack
41      ec.pushObject(getContext());
42    }
43  
44    public void end(InterpretationContext ec, String name) {
45      if (debugMode) {
46        addInfo("End of configuration.");
47        LoggerContext loggerContext = (LoggerContext) context;
48        StatusPrinter.print(loggerContext);
49        
50        //LoggerContext loggerContext = (LoggerContext) context;
51        //ConfiguratorBase.detachTemporaryConsoleAppender(repository, errorList);
52      }
53      ec.popObject();
54    }
55  }