java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.logging.GlobalLog |
Global logging facility used by JEB. This class offers methods to create per-class loggers. Upon initialization, a JEB client should add destination streams and buffers.
Implementation note: The official RCP client implementation provided with JEB registers stdout as well as the UI console window as destinations.
This class is thread-safe. However, ILogger
instances returned by getLogger()
are not thread-safe.
How to use:
import com.pnfsoftware.jeb.util.logging.ILogger; import com.pnfsoftware.jeb.util.loggingg.GlobalLog; class Xyz { private static final ILogger logger = GlobalLog.getLogger(Xyz.class); ... }
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | LEVEL_ALL | ||||||||||
int | LEVEL_ALWAYS_ON | ||||||||||
int | LEVEL_CATCHING | Special level used to log exception related data such as stack traces. | |||||||||
int | LEVEL_DEBUG | ||||||||||
int | LEVEL_DISABLED | ||||||||||
int | LEVEL_ERROR | ||||||||||
int | LEVEL_INFO | ||||||||||
int | LEVEL_INTERNAL | Reserved for internal use | |||||||||
int | LEVEL_STATUS | special log level indicating a status message; logs with that status will not be directed to the regular sinks | |||||||||
int | LEVEL_TRACE | ||||||||||
int | LEVEL_WARN |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final List<String> | LEVEL_NAMES | ||||||||||
public static final int | STANDARD_CUTOFF_LEVEL | ||||||||||
public static boolean | prefixWithLevel |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GlobalLog() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
synchronized static BufferSink |
addDestinationBuffer(List<CharSequence> buffer)
Add a destination buffer to the list of log message recipients.
| ||||||||||
synchronized static StreamSink |
addDestinationStream(OutputStream out)
Add a destination stream to the list of log message recipients.
| ||||||||||
synchronized static void | addGlobalFilter(String pattern, int requiredLevel) | ||||||||||
synchronized static void |
addStatusSink(LogStatusSink sink)
Register a status sink.
| ||||||||||
static void | catching(ILogger logger, Throwable t, String message) | ||||||||||
static void | catching(ILogger logger, Throwable t) | ||||||||||
static void | catchingDebug(ILogger logger, Throwable t) | ||||||||||
static void | catchingDebug(ILogger logger, Throwable t, String message) | ||||||||||
synchronized static void | clearGlobalFilters() | ||||||||||
static int | getCutoffLevel() | ||||||||||
synchronized static List<BufferSink> |
getDestinationBuffers()
Get the list of registered buffer sinks.
| ||||||||||
synchronized static List<StreamSink> |
getDestinationStreams()
Get the list of registered stream sinks.
| ||||||||||
synchronized static int |
getEnabledLevel()
Get the default logging level.
| ||||||||||
synchronized static ILogger |
getInternalLogger(Class<?> clazz)
Create or retrieve an internal logger.
| ||||||||||
static int |
getLevelFromPrefixLetter(char ch)
Retrieve the log level associated to the provided prefix letter.
| ||||||||||
synchronized static ILogger |
getLogger(Class<?> clazz)
Create or retrieve a logger attached to and named after a given class.
| ||||||||||
synchronized static ILogger |
getLogger()
Create or retrieve the anonymous logger.
| ||||||||||
synchronized static ILogger |
getLogger(String name, int level)
Create or retrieve a named logger.
| ||||||||||
synchronized static ILogger |
getLogger(Class<?> clazz, int level)
Create or retrieve a logger attached to and named after a given class.
| ||||||||||
static char |
getPrefixLetterForLevel(int level)
Retrieve the prefix letter associated to the provided log level.
| ||||||||||
synchronized static List<Sink<?>> |
getRegularSinks()
Get a list of the regular (= non status) sinks.
| ||||||||||
synchronized static List<LogStatusSink> | getStatusSinks() | ||||||||||
synchronized static boolean | isGloballyDisabled(ILogger logger) | ||||||||||
static String | levelToString(int level) | ||||||||||
static int |
parseLevel(String s)
Parse a log level name (or number) to a log level integer usable by Logger objects.
| ||||||||||
synchronized static BufferSink |
removeDestinationBuffer(List<CharSequence> buffer)
Remove a destination buffer.
| ||||||||||
synchronized static StreamSink |
removeDestinationStream(OutputStream out)
Remove a destination stream.
| ||||||||||
synchronized static void | removeGlobalFilter(String pattern) | ||||||||||
synchronized static void |
removeStatusSink(LogStatusSink sink)
Unregister a status sink.
| ||||||||||
synchronized static int | setCutoffLevel(int cutoffLevel) | ||||||||||
synchronized static void | setGlobalFilter(boolean mute) | ||||||||||
static int |
setLevelForNewLoggers(int level)
Set the default logging level
| ||||||||||
synchronized static int | setLevelForNewLoggers(int level, boolean updateExistingLoggers) | ||||||||||
synchronized static void |
status(String format, Object... params)
Convenience method for
getLogger().status(...) . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Special level used to log exception related data such as stack traces. Messages above or equal to this level are never neutered. Eg, disabling a logger will not disable CATCHING messages to go through.
Reserved for internal use
special log level indicating a status message; logs with that status will not be directed to the regular sinks
Add a destination buffer to the list of log message recipients. The list implementation must be thread-safe: it should be an object returned by Collections.synchronizedList()
buffer | the thread-safe buffer |
---|
Add a destination stream to the list of log message recipients.
out | a destination stream |
---|
Register a status sink. Those sinks receive only logs having the special level
LEVEL_STATUS
.
Get the list of registered buffer sinks.
Get the list of registered stream sinks.
Get the default logging level.
Create or retrieve an internal logger. INTERNAL USAGE ONLY.
Retrieve the log level associated to the provided prefix letter.
ch | prefix letter |
---|
Create or retrieve a logger attached to and named after a given class. If created, the logging level is set to the default global logging level.
clazz | class reference |
---|
Create or retrieve the anonymous logger. If created, the logging level is set to the default global logging level.
Create or retrieve a named logger.
name | logger name |
---|---|
level | the cut-off level |
Create or retrieve a logger attached to and named after a given class.
clazz | class reference |
---|---|
level | the cut-off level |
Retrieve the prefix letter associated to the provided log level.
level | log level |
---|
Get a list of the regular (= non status) sinks.
Parse a log level name (or number) to a log level integer usable by Logger objects. On error, this method returns a negative value. Negative value are illegal log levels.
s | a log level name or integer as a string |
---|
Remove a destination buffer.
buffer | the destination buffer |
---|
Remove a destination stream.
out | the destination stream |
---|
cutoffLevel | new level |
---|
Set the default logging level
level | the default logging level |
---|
Convenience method for getLogger().status(...)
.