1
2
3
4 package org.rcfaces.core.internal.service.log;
5
6 import javax.faces.component.UIViewRoot;
7 import javax.faces.context.FacesContext;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11 import org.apache.commons.logging.impl.Jdk14Logger;
12 import org.apache.commons.logging.impl.Log4JLogger;
13 import org.rcfaces.core.internal.service.AbstractService;
14
15
16
17
18
19
20 public abstract class LogService extends AbstractService {
21
22 private static final String REVISION = "$Revision: 1.18 $";
23
24 private static final Log LOG = LogFactory.getLog(LogService.class);
25
26 public static final String PREFIX_LOGGER_NAME = "org.rcfaces.client";
27
28 protected static final IFilter[] EMPTY_FILTERS = new IFilter[0];
29
30 private final Object LOGGER_LOCK = new Object();
31
32 private ILogger logger;
33
34 protected ILogger getLogger() {
35 synchronized (LOGGER_LOCK) {
36 if (logger != null) {
37 return logger;
38 }
39
40 try {
41 if (LOG instanceof Log4JLogger) {
42 logger = new Log4jLogger();
43 }
44
45 } catch (Throwable th) {
46
47 }
48
49 try {
50 if (LOG instanceof Jdk14Logger) {
51 logger = new Java14Logger();
52 }
53
54 } catch (Throwable th) {
55
56 }
57
58 if (logger == null) {
59 logger = new CommonsLogger();
60 }
61 }
62 return logger;
63 }
64
65 public interface IFilter {
66 String getName();
67
68 int getLevel();
69 }
70
71 public interface ILogger {
72 void logException(FacesContext facesContext, UIViewRoot viewRoot,
73 String name, long date, String message, int level,
74 Throwable exception);
75
76 IFilter[] listFilters(FacesContext facesContext);
77 }
78
79 public final IFilter[] listFilters(FacesContext facesContext) {
80 return getLogger().listFilters(facesContext);
81 }
82
83
84
85
86
87
88 public static class Filter implements IFilter {
89 private static final String REVISION = "$Revision: 1.18 $";
90
91 private final int level;
92
93 private final String name;
94
95 public Filter(int level, String name) {
96 this.level = level;
97 this.name = name;
98 }
99
100 public String getName() {
101 return name;
102 }
103
104 public int getLevel() {
105 return level;
106 }
107 }
108 }