public class BundleLogger extends AbstractLogger
BundleLogger
defines a simple API to enable some logging on behalf of
an extended bundle. This avoids that all clients doing logging on behalf of
a component bundle need to pass in things like BundleContext
.Modifier and Type | Field and Description |
---|---|
protected org.osgi.util.tracker.ServiceTracker<Object,Object> |
logServiceTracker |
protected int |
trackingCount |
Constructor and Description |
---|
BundleLogger(org.osgi.framework.BundleContext bundleContext,
ScrLogger parent) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the logger
|
boolean |
log(int level,
String message,
Throwable ex)
Method to actually emit the log message.
|
boolean |
log(int level,
String pattern,
Throwable ex,
Object... arguments)
Method to actually emit the log message.
|
isLogEnabled
protected final org.osgi.util.tracker.ServiceTracker<Object,Object> logServiceTracker
protected volatile int trackingCount
public BundleLogger(org.osgi.framework.BundleContext bundleContext, ScrLogger parent)
public boolean log(int level, String pattern, Throwable ex, Object... arguments)
AbstractLogger
log
in class AbstractLogger
level
- The log level to log the message atpattern
- The java.text.MessageFormat
message format
string for preparing the messageex
- An optional Throwable
whose stack trace is written,arguments
- The format arguments for the pattern
string.public boolean log(int level, String message, Throwable ex)
AbstractLogger
log
in class AbstractLogger
level
- The log level of the messages. This corresponds to the log
levels defined by the OSGi LogService.message
- The message to printex
- The Throwable
causing the message to be logged.public void close()
Copyright © 2006–2020 The Apache Software Foundation. All rights reserved.