1
2 package org.csc.phynixx.common.logger;
3
4 /*
5 * #%L
6 * phynixx-common
7 * %%
8 * Copyright (C) 2014 csc
9 * %%
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * #L%
22 */
23
24
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 /**
29 * Implements {@link org.csc.phynixx.common.logger.IPhynixxLogger} on base of log4j
30 */
31 public class LogbackLogger implements IPhynixxLogger {
32
33 private Logger log = null;
34
35 LogbackLogger(Class cls) {
36 this.log = LoggerFactory.getLogger(cls);
37 }
38
39 LogbackLogger(String logger) {
40 this.log = LoggerFactory.getLogger(logger);
41 }
42
43 /* (non-Javadoc)
44 * @see de.csc.xaresource.sample.ILogger#debug(java.lang.Object)
45 */
46 public void debug(Object o) {
47 log.debug(toString(o));
48 }
49
50 private String toString(Object o) {
51 return (o==null)?"NULL":o.toString();
52 }
53
54 /* (non-Javadoc)
55 * @see de.csc.xaresource.sample.ILogger#debug(java.lang.Object, java.lang.Throwable)
56 */
57 public void debug(Object o, Throwable t) {
58 log.debug(toString(o), t);
59 }
60
61 /* (non-Javadoc)
62 * @see de.csc.xaresource.sample.ILogger#info(java.lang.Object)
63 */
64 public void info(Object o) {
65 log.info(toString(o));
66 }
67
68 /* (non-Javadoc)
69 * @see de.csc.xaresource.sample.ILogger#info(java.lang.Object, java.lang.Throwable)
70 */
71 public void info(Object o, Throwable t) {
72 log.info(toString(o), t);
73 }
74
75 /* (non-Javadoc)
76 * @see de.csc.xaresource.sample.ILogger#warn(java.lang.Object)
77 */
78 public void warn(Object o) {
79 log.warn(toString(o));
80 }
81
82 /* (non-Javadoc)
83 * @see de.csc.xaresource.sample.ILogger#warn(java.lang.Object, java.lang.Throwable)
84 */
85 public void warn(Object o, Throwable t) {
86 log.warn(toString(o), t);
87 }
88
89 /* (non-Javadoc)
90 * @see de.csc.xaresource.sample.ILogger#error(java.lang.Object)
91 */
92 public void error(Object o) {
93 log.error(toString(o));
94 }
95
96 /* (non-Javadoc)
97 * @see de.csc.xaresource.sample.ILogger#error(java.lang.Object, java.lang.Throwable)
98 */
99 public void error(Object o, Throwable t) {
100 log.error(toString(o), t);
101 }
102
103 /* (non-Javadoc)
104 * @see de.csc.xaresource.sample.ILogger#fatal(java.lang.Object)
105 */
106 public void fatal(Object o) {
107 log.error(toString(o));
108 }
109
110 /* (non-Javadoc)
111 * @see de.csc.xaresource.sample.ILogger#fatal(java.lang.Object, java.lang.Throwable)
112 */
113 public void fatal(Object o, Throwable t) {
114 log.error(toString(o), t);
115 }
116
117 public boolean isDebugEnabled() {
118 return log.isDebugEnabled();
119 }
120
121 public boolean isInfoEnabled() {
122 return log.isInfoEnabled();
123 }
124
125
126 }