-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from hjyun328/hjyun/develop
FEATURE: Adding support for SLF4J logging
- Loading branch information
Showing
10 changed files
with
421 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
// Copyright (c) 2002 SPY internetworking <[email protected]> | ||
/** | ||
* Copyright (C) 2006-2009 Dustin Sallings | ||
* Copyright (C) 2009-2013 Couchbase, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
package net.spy.memcached.compat.log; | ||
|
||
|
@@ -58,6 +79,37 @@ public Throwable getThrowable(Object args[]) { | |
*/ | ||
public abstract boolean isInfoEnabled(); | ||
|
||
/** | ||
* Log a message at trace level. | ||
* | ||
* @param message the message to log | ||
* @param exception the exception that caused the message to be generated | ||
*/ | ||
public void trace(Object message, Throwable exception) { | ||
log(Level.TRACE, message, exception); | ||
} | ||
|
||
/** | ||
* Log a formatted message at trace level. | ||
* | ||
* @param message the message to log | ||
* @param args the arguments for that message | ||
*/ | ||
public void trace(String message, Object... args) { | ||
if (isDebugEnabled()) { | ||
trace(String.format(message, args), getThrowable(args)); | ||
} | ||
} | ||
|
||
/** | ||
* Log a message at trace level. | ||
* | ||
* @param message the message to log | ||
*/ | ||
public void trace(Object message) { | ||
trace(message, null); | ||
} | ||
|
||
/** | ||
* Log a message at debug level. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
// Copyright (c) 2002 SPY internetworking <[email protected]> | ||
/** | ||
* Copyright (C) 2006-2009 Dustin Sallings | ||
* Copyright (C) 2009-2013 Couchbase, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
package net.spy.memcached.compat.log; | ||
|
||
|
@@ -23,6 +44,14 @@ public DefaultLogger(String name) { | |
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | ||
} | ||
|
||
/** | ||
* False. | ||
*/ | ||
@Override | ||
public boolean isTraceEnabled() { | ||
return (false); | ||
} | ||
|
||
/** | ||
* False. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
// Copyright (c) 2002 Dustin Sallings <[email protected]> | ||
/** | ||
* Copyright (C) 2006-2009 Dustin Sallings | ||
* Copyright (C) 2009-2013 Couchbase, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
package net.spy.memcached.compat.log; | ||
|
||
|
@@ -7,6 +28,10 @@ | |
*/ | ||
public enum Level { | ||
|
||
/** | ||
* Trace level. | ||
*/ | ||
TRACE, | ||
/** | ||
* Debug level. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
// Copyright (c) 2002 Dustin Sallings <[email protected]> | ||
/** | ||
* Copyright (C) 2006-2009 Dustin Sallings | ||
* Copyright (C) 2009-2013 Couchbase, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
package net.spy.memcached.compat.log; | ||
|
||
|
@@ -22,6 +43,14 @@ public Log4JLogger(String name) { | |
l4jLogger = org.apache.log4j.Logger.getLogger(name); | ||
} | ||
|
||
/** | ||
* True if the underlying logger would allow trace messages through. | ||
*/ | ||
@Override | ||
public boolean isTraceEnabled() { | ||
return (l4jLogger.isTraceEnabled()); | ||
} | ||
|
||
/** | ||
* True if the underlying logger would allow debug messages through. | ||
*/ | ||
|
@@ -41,7 +70,7 @@ public boolean isInfoEnabled() { | |
/** | ||
* Wrapper around log4j. | ||
* | ||
* @param level net.spy.compat.log.AbstractLogger level. | ||
* @param level net.spy.compat.log.Level level. | ||
* @param message object message | ||
* @param e optional throwable | ||
*/ | ||
|
@@ -50,6 +79,9 @@ public void log(Level level, Object message, Throwable e) { | |
org.apache.log4j.Level pLevel = org.apache.log4j.Level.DEBUG; | ||
|
||
switch (level == null ? Level.FATAL : level) { | ||
case TRACE: | ||
pLevel = org.apache.log4j.Level.TRACE; | ||
break; | ||
case DEBUG: | ||
pLevel = org.apache.log4j.Level.DEBUG; | ||
break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
// Copyright (c) 2002 SPY internetworking <[email protected]> | ||
/** | ||
* Copyright (C) 2006-2009 Dustin Sallings | ||
* Copyright (C) 2009-2013 Couchbase, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
package net.spy.memcached.compat.log; | ||
|
||
|
@@ -30,6 +51,13 @@ public interface Logger { | |
* @return true if info messages would be displayed | ||
*/ | ||
boolean isInfoEnabled(); | ||
|
||
/** | ||
* True if info is enabled for this logger. | ||
* | ||
* @return true if trace messages would be displayed | ||
*/ | ||
boolean isTraceEnabled(); | ||
|
||
/** | ||
* Log a message at the specified level. | ||
|
@@ -48,6 +76,29 @@ public interface Logger { | |
*/ | ||
void log(Level level, Object message); | ||
|
||
/** | ||
* Log a message at trace level. | ||
* | ||
* @param message the message to log | ||
* @param exception the exception that caused the message to be generated | ||
*/ | ||
void trace(Object message, Throwable exception); | ||
|
||
/** | ||
* Log a message at trace level. | ||
* | ||
* @param message the message to log | ||
*/ | ||
void trace(Object message); | ||
|
||
/** | ||
* Log a formatted message at trace level. | ||
* | ||
* @param message the message to log | ||
* @param args the arguments for that message | ||
*/ | ||
void trace(String message, Object... args); | ||
|
||
/** | ||
* Log a message at debug level. | ||
* | ||
|
Oops, something went wrong.