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.LevelModel;
19 import ch.qos.logback.core.joran.action.Action;
20 import ch.qos.logback.core.joran.JoranConstants;
21 import ch.qos.logback.core.joran.action.BaseModelAction;
22 import ch.qos.logback.core.joran.action.PreconditionValidator;
23 import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
24 import ch.qos.logback.core.model.Model;
25
26
27
28
29
30
31
32
33
34
35 public class LevelAction extends BaseModelAction {
36
37 @Override
38 protected boolean validPreconditions(SaxEventInterpretationContext interpcont, String name, Attributes attributes) {
39 PreconditionValidator pv = new PreconditionValidator(this, interpcont, name, attributes);
40 pv.validateValueAttribute();
41 addWarn("<level> element is deprecated. Near [" + name + "] on line " + Action.getLineNumber(interpcont));
42 addWarn("Please use \"level\" attribute within <logger> or <root> elements instead.");
43 return pv.isValid();
44 }
45
46 @Override
47 protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name,
48 Attributes attributes) {
49 LevelModel lm = new LevelModel();
50 String value = attributes.getValue(JoranConstants.VALUE_ATTR);
51 lm.setValue(value);
52
53 return lm;
54 }
55
56 }