View Javadoc

1   /**
2    * LOGBack: the reliable, fast and flexible logging library for Java.
3    *
4    * Copyright (C) 1999-2006, QOS.ch
5    *
6    * This library is free software, you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public License as
8    * published by the Free Software Foundation.
9    */
10  package ch.qos.logback.classic.pattern;
11  
12  import ch.qos.logback.classic.LoggerContext;
13  import ch.qos.logback.classic.spi.LoggerContextAware;
14  import ch.qos.logback.classic.spi.LoggerContextAwareBase;
15  import ch.qos.logback.classic.spi.LoggingEvent;
16  import ch.qos.logback.core.Context;
17  import ch.qos.logback.core.pattern.DynamicConverter;
18  import ch.qos.logback.core.status.Status;
19  
20  
21  /**
22   * This class serves the super-class of all converters in logback. It extends
23   * {@link DynamicConverter} and also implements {@link LoggerContextAware}.
24   * 
25   * @author Ceki Gulcu
26   */
27  abstract public class ClassicConverter extends DynamicConverter<LoggingEvent> implements
28      LoggerContextAware {
29  
30    LoggerContextAwareBase lcab = new LoggerContextAwareBase();
31  
32    public void setLoggerContext(LoggerContext lc) {
33      lcab.setLoggerContext(lc);
34    }
35  
36    public void setContext(Context context) {
37      lcab.setContext(context);
38    }
39  
40    public Context getContext() {
41      return lcab.getContext();
42    }
43    
44    public void addStatus(Status status) {
45      lcab.addStatus(status);
46    }
47  
48    public void addInfo(String msg) {
49      lcab.addInfo(msg);
50    }
51  
52    public void addInfo(String msg, Throwable ex) {
53      lcab.addInfo(msg, ex);
54    }
55  
56    public void addWarn(String msg) {
57      lcab.addWarn(msg);
58    }
59  
60    public void addWarn(String msg, Throwable ex) {
61      lcab.addWarn(msg, ex);
62    }
63  
64    public void addError(String msg) {
65      lcab.addError(msg);
66    }
67  
68    public void addError(String msg, Throwable ex) {
69      lcab.addError(msg, ex);
70    }
71  
72  }