View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2009, 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.pattern;
15  
16  import ch.qos.logback.classic.LoggerContext;
17  import ch.qos.logback.classic.spi.LoggerContextAware;
18  import ch.qos.logback.classic.spi.LoggerContextAwareBase;
19  import ch.qos.logback.classic.spi.ILoggingEvent;
20  import ch.qos.logback.core.Context;
21  import ch.qos.logback.core.pattern.DynamicConverter;
22  import ch.qos.logback.core.status.Status;
23  
24  
25  /**
26   * This class serves the super-class of all converters in logback. It extends
27   * {@link DynamicConverter} and also implements {@link LoggerContextAware}.
28   * 
29   * @author Ceki Gulcu
30   */
31  abstract public class ClassicConverter extends DynamicConverter<ILoggingEvent> implements
32      LoggerContextAware {
33  
34    LoggerContextAwareBase lcab = new LoggerContextAwareBase();
35  
36    public void setLoggerContext(LoggerContext lc) {
37      lcab.setLoggerContext(lc);
38    }
39  
40    public void setContext(Context context) {
41      lcab.setContext(context);
42    }
43  
44    public Context getContext() {
45      return lcab.getContext();
46    }
47    
48    public void addStatus(Status status) {
49      lcab.addStatus(status);
50    }
51  
52    public void addInfo(String msg) {
53      lcab.addInfo(msg);
54    }
55  
56    public void addInfo(String msg, Throwable ex) {
57      lcab.addInfo(msg, ex);
58    }
59  
60    public void addWarn(String msg) {
61      lcab.addWarn(msg);
62    }
63  
64    public void addWarn(String msg, Throwable ex) {
65      lcab.addWarn(msg, ex);
66    }
67  
68    public void addError(String msg) {
69      lcab.addError(msg);
70    }
71  
72    public void addError(String msg, Throwable ex) {
73      lcab.addError(msg, ex);
74    }
75  
76  }