You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2014/11/25 17:26:26 UTC
[04/48] jena git commit: Add Class> log selector variants.
Add Class<?> log selector variants.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/890ff39b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/890ff39b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/890ff39b
Branch: refs/heads/hadoop-rdf
Commit: 890ff39b99c99eacb963b3dcacab6e34f1022597
Parents: 5896fa6
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 11 15:36:30 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 11 15:36:30 2014 +0000
----------------------------------------------------------------------
.../org/apache/jena/atlas/logging/FmtLog.java | 61 +++++++++++++++++++-
1 file changed, 59 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/890ff39b/jena-arq/src/main/java/org/apache/jena/atlas/logging/FmtLog.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/atlas/logging/FmtLog.java b/jena-arq/src/main/java/org/apache/jena/atlas/logging/FmtLog.java
index 640c83b..590c49e 100644
--- a/jena-arq/src/main/java/org/apache/jena/atlas/logging/FmtLog.java
+++ b/jena-arq/src/main/java/org/apache/jena/atlas/logging/FmtLog.java
@@ -21,6 +21,7 @@ package org.apache.jena.atlas.logging;
import java.util.IllegalFormatException ;
import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
/** Logging with String.format (which can be a expensive)
* The formatting operations are not designed specifically for performance,
@@ -29,7 +30,9 @@ import org.slf4j.Logger ;
* required by level setting.
*
* An odd effect is order of the arguments - vararg arguments must be last
- * so the order is Logger/Format/Thorwable?/args
+ * so the order is Logger/Thorwable?/Format/args.
+ *
+ * Also support: Class object instead of logger to help ad hoc usage.
*/
public class FmtLog {
/* Log at 'trace' level. */
@@ -44,6 +47,16 @@ public class FmtLog {
log.trace(format(fmt, args), th) ;
}
+ /* Log at 'trace' level. */
+ public static void trace(Class<?> cls, String fmt, Object...args) {
+ trace(log(cls), fmt, args) ;
+ }
+
+ /* Log at 'trace' level. */
+ public static void trace(Class<?> cls, Throwable th, String fmt, Object...args) {
+ trace(log(cls), th, fmt, args) ;
+ }
+
/* Log at 'debug' level */
public static void debug(Logger log, String fmt, Object...args) {
if ( log.isDebugEnabled() )
@@ -56,6 +69,16 @@ public class FmtLog {
log.debug(format(fmt, args), th) ;
}
+ /* Log at 'debug' level */
+ public static void debug(Class<?> cls, String fmt, Object...args) {
+ debug(log(cls), fmt, args) ;
+ }
+
+ /* Log at 'debug' level */
+ public static void debug(Class<?> cls, Throwable th, String fmt, Object...args) {
+ debug(log(cls), th, fmt, args) ;
+ }
+
/* Log at 'info' level */
public static void info(Logger log, String fmt, Object...args) {
if ( log.isInfoEnabled() )
@@ -68,6 +91,15 @@ public class FmtLog {
log.info(format(fmt, args), th) ;
}
+ /* Log at 'info' level */
+ public static void info(Class<?> cls, String fmt, Object...args) {
+ info(log(cls), fmt, args) ;
+ }
+
+ /* Log at 'info' level */
+ public static void info(Class<?> cls, Throwable th, String fmt, Object...args) {
+ info(log(cls), th, fmt, args) ;
+ }
/* Log at 'warn' level */
public static void warn(Logger log, String fmt, Object...args) {
@@ -81,7 +113,17 @@ public class FmtLog {
log.warn(format(fmt, args), th) ;
}
- /* Log at 'error' level */
+ /* Log at 'warn' level */
+ public static void warn(Class<?> cls, String fmt, Object...args) {
+ warn(log(cls), fmt, args) ;
+ }
+
+ /* Log at 'warn' level */
+ public static void warn(Class<?> cls, Throwable th, String fmt, Object...args) {
+ warn(log(cls), th, fmt, args) ;
+ }
+
+ /* Log at 'error' level */
public static void error(Logger log, String fmt, Object...args) {
if ( log.isErrorEnabled() )
log.error(format(fmt, args)) ;
@@ -93,6 +135,17 @@ public class FmtLog {
log.error(format(fmt, args), th) ;
}
+ /* Log at 'error' level */
+ public static void error(Class<?> cls, String fmt, Object...args) {
+ error(log(cls), fmt, args) ;
+ }
+
+ /* Log at 'error' level */
+ public static void error(Class<?> cls, Throwable th, String fmt, Object...args) {
+ error(log(cls), th, fmt, args) ;
+ }
+
+
private static String format(String fmt, Object[] args) {
try {
return String.format(fmt, args) ;
@@ -101,5 +154,9 @@ public class FmtLog {
return fmt+" "+args ;
}
}
+
+ private static Logger log(Class<?> cls) {
+ return LoggerFactory.getLogger(cls) ;
+ }
}