1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.taglib;
18
19 import org.apache.logging.log4j.Level;
20
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.tagext.DynamicAttributes;
23 import javax.servlet.jsp.tagext.Tag;
24 import java.util.ArrayList;
25 import java.util.List;
26
27
28
29
30
31
32 public class EntryTag extends LoggerAwareTagSupport implements DynamicAttributes {
33 private static final long serialVersionUID = 1L;
34
35 private static final String FQCN = EntryTag.class.getName();
36
37 private List<Object> attributes;
38
39 @Override
40 protected void init() {
41 super.init();
42 if (this.attributes == null) {
43 this.attributes = new ArrayList<Object>();
44 } else {
45 this.attributes.clear();
46 }
47 }
48
49 public void setDynamicAttribute(String uri, String name, Object value) {
50 this.attributes.add(value);
51 }
52
53 @Override
54 public int doEndTag() throws JspException {
55 Log4jTaglibLogger logger = this.getLogger();
56
57 if (TagUtils.isEnabled(logger, Level.TRACE, null)) {
58 if (this.attributes.size() == 0) {
59 logger.entry(FQCN);
60 } else {
61 logger.entry(FQCN, this.attributes.toArray());
62 }
63 }
64
65 return Tag.EVAL_PAGE;
66 }
67 }