1
2
3
4
5
6
7
8
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
35
36
37 debugMode = true;
38 }
39
40
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
51
52 }
53 ec.popObject();
54 }
55 }