View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.control;
15  
16  import org.slf4j.Marker;
17  import org.slf4j.helpers.LegacyAbstractLogger;
18  
19  import ch.qos.logback.classic.Level;
20  
21  /**
22   * See javadoc for ControlLoggerContext.
23   */
24  public class ControlLogger extends LegacyAbstractLogger {
25  
26      private static final long serialVersionUID = 1L;
27      final ControlLogger parent;
28      final String name;
29      Level level;
30  
31      public ControlLogger(String name, ControlLogger parent) {
32          if (name == null) {
33              throw new IllegalArgumentException("name cannot be null");
34          }
35          this.name = name;
36          this.parent = parent;
37      }
38  
39      public String getName() {
40          return name;
41      }
42  
43      public Level getLevel() {
44          return level;
45      }
46  
47      public void setLevel(Level level) {
48          this.level = level;
49      }
50  
51      public final Level getEffectiveLevel() {
52          for (ControlLogger cl = this; cl != null; cl = cl.parent) {
53              if (cl.level != null)
54                  return cl.level;
55          }
56          return null; // If reached will cause an NullPointerException.
57      }
58  
59      public boolean equals(Object o) {
60          if (this == o)
61              return true;
62          if (!(o instanceof ControlLogger))
63              return false;
64  
65          final ControlLogger controlLogger = (ControlLogger) o;
66          return name.equals(controlLogger.name);
67      }
68  
69      public int hashCode() {
70          return name.hashCode();
71      }
72  
73      public final void trace(String o) {
74          if (getEffectiveLevel().levelInt <= Level.TRACE_INT) {
75              throw new UnsupportedOperationException("not yet implemented");
76          }
77      }
78  
79      public final void debug(String o) {
80          if (getEffectiveLevel().levelInt <= Level.DEBUG_INT) {
81              throw new UnsupportedOperationException("not yet implemented");
82          }
83      }
84  
85      @Override
86      protected String getFullyQualifiedCallerName() {
87          return ControlLogger.class.getName();
88      }
89  
90      @Override
91      protected void handleNormalizedLoggingCall(org.slf4j.event.Level level, Marker marker, String msg,
92              Object[] arguments, Throwable throwable) {
93          // TODO Auto-generated method stub
94  
95      }
96  
97      @Override
98      public boolean isTraceEnabled() {
99          return false;
100     }
101 
102     @Override
103     public boolean isDebugEnabled() {
104         return false;
105     }
106 
107     @Override
108     public boolean isInfoEnabled() {
109         return false;
110     }
111 
112     @Override
113     public boolean isWarnEnabled() {
114         return false;
115     }
116 
117     @Override
118     public boolean isErrorEnabled() {
119         return false;
120     }
121 
122 }