Package org.apache.felix.utils.log
Class Logger
- java.lang.Object
-
- org.apache.felix.utils.log.Logger
-
public class Logger extends java.lang.ObjectInternal logger to be used in order to avoid a mandatory dependency on OSGi LogService. It first tries to log to a log service implementation if there is one available and then fallback to System out/err in case there is no log service available.
-
-
Field Summary
Fields Modifier and Type Field Description static intLOG_DEBUGstatic intLOG_ERRORstatic intLOG_INFOstatic intLOG_WARNINGprivate org.osgi.framework.BundleContextm_contextBundle context.private booleanm_isLogClassPresent
-
Constructor Summary
Constructors Constructor Description Logger(org.osgi.framework.BundleContext context)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean_log(int level, java.lang.String message, java.lang.Throwable exception)Lookup the OSGi LogService and if available use it.private java.io.PrintStreamgetStream(int level)Return the standard print streams to use depending on log level.voidlog(int level, java.lang.String message)Logs a message.voidlog(int level, java.lang.String message, java.lang.Throwable exception)Logs a message.
-
-
-
Field Detail
-
LOG_ERROR
public static final int LOG_ERROR
- See Also:
- Constant Field Values
-
LOG_WARNING
public static final int LOG_WARNING
- See Also:
- Constant Field Values
-
LOG_INFO
public static final int LOG_INFO
- See Also:
- Constant Field Values
-
LOG_DEBUG
public static final int LOG_DEBUG
- See Also:
- Constant Field Values
-
m_context
private final org.osgi.framework.BundleContext m_context
Bundle context.
-
m_isLogClassPresent
private boolean m_isLogClassPresent
-
-
Method Detail
-
log
public void log(int level, java.lang.String message)Logs a message.- Parameters:
level- The severity of the message. Tmessage- Human readable string describing the condition ornull.- See Also:
LogService.log(int, String)
-
log
public void log(int level, java.lang.String message, java.lang.Throwable exception)Logs a message.- Parameters:
level- The severity of the message. Tmessage- Human readable string describing the condition ornull.exception- The exception that reflects the condition ornull.- See Also:
LogService.log(int, String, Throwable)
-
_log
private boolean _log(int level, java.lang.String message, java.lang.Throwable exception)Lookup the OSGi LogService and if available use it.
-
getStream
private java.io.PrintStream getStream(int level)
Return the standard print streams to use depending on log level.- Parameters:
level- log level- Returns:
- print stream corresponding to log level
-
-