1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.joran.action;
15
16 import org.xml.sax.Attributes;
17
18 import ch.qos.logback.classic.model.LoggerModel;
19 import ch.qos.logback.core.joran.JoranConstants;
20 import ch.qos.logback.core.joran.action.BaseModelAction;
21 import ch.qos.logback.core.joran.action.PreconditionValidator;
22 import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
23 import ch.qos.logback.core.model.Model;
24
25
26
27
28
29
30 public class LoggerAction extends BaseModelAction {
31
32 @Override
33 protected boolean validPreconditions(SaxEventInterpretationContext ic, String name, Attributes attributes) {
34 PreconditionValidator validator = new PreconditionValidator(this, ic, name, attributes);
35 validator.validateNameAttribute();
36 return validator.isValid();
37 }
38
39 @Override
40 protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name,
41 Attributes attributes) {
42
43 LoggerModel loggerModel = new LoggerModel();
44
45 String nameStr = attributes.getValue(NAME_ATTRIBUTE);
46 loggerModel.setName(nameStr);
47
48 String levelStr = attributes.getValue(JoranConstants.LEVEL_ATTRIBUTE);
49 loggerModel.setLevel(levelStr);
50
51 String additivityStr = attributes.getValue(JoranConstants.ADDITIVITY_ATTRIBUTE);
52 loggerModel.setAdditivity(additivityStr);
53
54 return loggerModel;
55 }
56 }