Package org.apache.felix.scr.impl.logger
Class ComponentLogger
- java.lang.Object
-
- org.apache.felix.scr.impl.logger.AbstractLogger
-
- org.apache.felix.scr.impl.logger.ComponentLogger
-
public class ComponentLogger extends AbstractLogger
TheComponentLoggeris the logger to be used to log on behalf of a component. This avoids avoids that all clients doing logging on behalf of a component need to pass in things likeComponentMetadataor the component Id.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassNameprivate InternalLoggercurrentLoggerprivate java.lang.Stringnameprivate BundleLoggerparentprivate inttrackingCount
-
Constructor Summary
Constructors Constructor Description ComponentLogger(ComponentMetadata metadata, BundleLogger parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) InternalLoggergetLogger()Get the internal loggerbooleanlog(int level, java.lang.String message, java.lang.Throwable ex)Method to actually emit the log message.booleanlog(int level, java.lang.String pattern, java.lang.Throwable ex, java.lang.Object... arguments)Method to actually emit the log message.voidsetComponentId(long id)Update the logger with the correct component id.-
Methods inherited from class org.apache.felix.scr.impl.logger.AbstractLogger
getBundleIdentifier, getConfiguration, getPrefix, isLogEnabled, setPrefix
-
-
-
-
Field Detail
-
name
private final java.lang.String name
-
className
private final java.lang.String className
-
parent
private final BundleLogger parent
-
trackingCount
private volatile int trackingCount
-
currentLogger
private volatile InternalLogger currentLogger
-
-
Constructor Detail
-
ComponentLogger
public ComponentLogger(ComponentMetadata metadata, BundleLogger parent)
-
-
Method Detail
-
setComponentId
public void setComponentId(long id)
Update the logger with the correct component id.- Parameters:
id- The component id
-
getLogger
InternalLogger getLogger()
Description copied from class:AbstractLoggerGet the internal logger- Specified by:
getLoggerin classAbstractLogger- Returns:
- The internal logger
-
log
public boolean log(int level, java.lang.String pattern, java.lang.Throwable ex, java.lang.Object... arguments)Description copied from class:AbstractLoggerMethod to actually emit the log message. If the LogService is available, the message will be logged through the LogService. Otherwise the message is logged to stdout (or stderr in case of LOG_ERROR level messages),- Overrides:
login classAbstractLogger- Parameters:
level- The log level to log the message atpattern- Thejava.text.MessageFormatmessage format string for preparing the messageex- An optionalThrowablewhose stack trace is written,arguments- The format arguments for thepatternstring.
-
log
public boolean log(int level, java.lang.String message, java.lang.Throwable ex)Description copied from class:AbstractLoggerMethod to actually emit the log message. If the LogService is available, the message will be logged through the LogService. Otherwise the message is logged to stdout (or stderr in case of LOG_ERROR level messages),- Overrides:
login classAbstractLogger- Parameters:
level- The log level of the messages. This corresponds to the log levels defined by the OSGi LogService.message- The message to printex- TheThrowablecausing the message to be logged.
-
-