comparison src/org/eclipse/jetty/util/log/Slf4jLog.java @ 802:3428c60d7cfc

replace jetty jars with source
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Sep 2016 21:15:48 -0600
parents
children
comparison
equal deleted inserted replaced
801:6a21393191c1 802:3428c60d7cfc
1 //
2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.util.log;
20
21
22
23 /**
24 * Slf4jLog Logger
25 */
26 public class Slf4jLog extends AbstractLogger
27 {
28 private final org.slf4j.Logger _logger;
29
30 public Slf4jLog() throws Exception
31 {
32 this("org.eclipse.jetty.util.log");
33 }
34
35 public Slf4jLog(String name)
36 {
37 //NOTE: if only an slf4j-api jar is on the classpath, slf4j will use a NOPLogger
38 org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger( name );
39
40 // Fix LocationAwareLogger use to indicate FQCN of this class -
41 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276670
42 if (logger instanceof org.slf4j.spi.LocationAwareLogger)
43 {
44 _logger = new JettyAwareLogger((org.slf4j.spi.LocationAwareLogger)logger);
45 }
46 else
47 {
48 _logger = logger;
49 }
50 }
51
52 public String getName()
53 {
54 return _logger.getName();
55 }
56
57 public void warn(String msg, Object... args)
58 {
59 _logger.warn(msg, args);
60 }
61
62 public void warn(Throwable thrown)
63 {
64 warn("", thrown);
65 }
66
67 public void warn(String msg, Throwable thrown)
68 {
69 _logger.warn(msg, thrown);
70 }
71
72 public void info(String msg, Object... args)
73 {
74 _logger.info(msg, args);
75 }
76
77 public void info(Throwable thrown)
78 {
79 info("", thrown);
80 }
81
82 public void info(String msg, Throwable thrown)
83 {
84 _logger.info(msg, thrown);
85 }
86
87 public void debug(String msg, Object... args)
88 {
89 _logger.debug(msg, args);
90 }
91
92 public void debug(Throwable thrown)
93 {
94 debug("", thrown);
95 }
96
97 public void debug(String msg, Throwable thrown)
98 {
99 _logger.debug(msg, thrown);
100 }
101
102 public boolean isDebugEnabled()
103 {
104 return _logger.isDebugEnabled();
105 }
106
107 public void setDebugEnabled(boolean enabled)
108 {
109 warn("setDebugEnabled not implemented",null,null);
110 }
111
112 /**
113 * Create a Child Logger of this Logger.
114 */
115 protected Logger newLogger(String fullname)
116 {
117 return new Slf4jLog(fullname);
118 }
119
120 public void ignore(Throwable ignored)
121 {
122 if (Log.isIgnored())
123 {
124 warn(Log.IGNORED, ignored);
125 }
126 }
127
128 @Override
129 public String toString()
130 {
131 return _logger.toString();
132 }
133 }