01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.logging;
05:
06: import com.tc.net.protocol.tcm.ChannelIDProvider;
07:
08: public class ChannelIDLogger implements TCLogger {
09:
10: private final ChannelIDProvider cidp;
11: private final TCLogger logger;
12:
13: public ChannelIDLogger(ChannelIDProvider channelIDProvider,
14: TCLogger logger) {
15: this .cidp = channelIDProvider;
16: this .logger = logger;
17: }
18:
19: public void debug(Object message) {
20: logger.debug(msg(message));
21: }
22:
23: public void debug(Object message, Throwable t) {
24: logger.debug(msg(message), t);
25: }
26:
27: public void error(Object message) {
28: logger.error(msg(message));
29: }
30:
31: public void error(Object message, Throwable t) {
32: logger.error(msg(message), t);
33: }
34:
35: public void fatal(Object message) {
36: logger.fatal(msg(message));
37: }
38:
39: public void fatal(Object message, Throwable t) {
40: logger.fatal(msg(message), t);
41: }
42:
43: public void info(Object message) {
44: logger.info(msg(message));
45: }
46:
47: public void info(Object message, Throwable t) {
48: logger.info(msg(message), t);
49: }
50:
51: public void warn(Object message) {
52: logger.warn(msg(message));
53: }
54:
55: public void warn(Object message, Throwable t) {
56: logger.warn(msg(message), t);
57: }
58:
59: public void log(LogLevel level, Object message) {
60: logger.log(level, msg(message));
61: }
62:
63: public void log(LogLevel level, Object message, Throwable t) {
64: logger.log(level, msg(message), t);
65: }
66:
67: public boolean isDebugEnabled() {
68: return logger.isDebugEnabled();
69: }
70:
71: public boolean isInfoEnabled() {
72: return logger.isInfoEnabled();
73: }
74:
75: public void setLevel(LogLevel level) {
76: logger.setLevel(level);
77: }
78:
79: public LogLevel getLevel() {
80: return logger.getLevel();
81: }
82:
83: private Object msg(Object msg) {
84: return cidp.getChannelID() + ": " + msg;
85: }
86:
87: public String getName() {
88: return logger.getName();
89: }
90:
91: }
|