public class

GlobalLog

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.logging.GlobalLog

Class Overview

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);
     ...
 }
 

Summary

Constants
int LEVEL_ALL
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_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
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(boolean mute)
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()
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.
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.
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 void setEnabledLevel(int level)
Set the default logging level
synchronized static void setEnabledLevel(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

Constants

public static final int LEVEL_ALL

Constant Value: 0 (0x00000000)

public static final int LEVEL_CATCHING

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.

Constant Value: 60 (0x0000003c)

public static final int LEVEL_DEBUG

Constant Value: 20 (0x00000014)

public static final int LEVEL_DISABLED

Constant Value: 2147483647 (0x7fffffff)

public static final int LEVEL_ERROR

Constant Value: 50 (0x00000032)

public static final int LEVEL_INFO

Constant Value: 30 (0x0000001e)

public static final int LEVEL_STATUS

special log level indicating a status message; logs with that status will not be directed to the regular sinks

Constant Value: 100 (0x00000064)

public static final int LEVEL_TRACE

Constant Value: 10 (0x0000000a)

public static final int LEVEL_WARN

Constant Value: 40 (0x00000028)

Public Constructors

public GlobalLog ()

Public Methods

public static synchronized BufferSink addDestinationBuffer (List<CharSequence> buffer)

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()

Parameters
buffer the thread-safe buffer
Returns
  • the sink

public static synchronized StreamSink addDestinationStream (OutputStream out)

Add a destination stream to the list of log message recipients.

Parameters
out a destination stream
Returns
  • the sink

public static synchronized void addGlobalFilter (boolean mute)

public static synchronized void addGlobalFilter (String pattern, int requiredLevel)

public static synchronized void addStatusSink (LogStatusSink sink)

Register a status sink. Those sinks receive only logs having the special level LEVEL_STATUS.

public static void catching (ILogger logger, Throwable t, String message)

public static void catching (ILogger logger, Throwable t)

public static void catchingDebug (ILogger logger, Throwable t)

public static void catchingDebug (ILogger logger, Throwable t, String message)

public static synchronized void clearGlobalFilters ()

public static synchronized List<BufferSink> getDestinationBuffers ()

Get the list of registered buffer sinks.

Returns
  • the list of buffer sinks

public static synchronized List<StreamSink> getDestinationStreams ()

Get the list of registered stream sinks.

Returns
  • the list of stream sinks

public static synchronized int getEnabledLevel ()

Get the default logging level.

Returns
  • the default logging level

public static synchronized ILogger getInternalLogger (Class<?> clazz)

Create or retrieve an internal logger. INTERNAL USAGE ONLY.

public static synchronized ILogger getLogger (Class<?> clazz)

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.

Parameters
clazz class reference
Returns
  • the logger

public static synchronized ILogger getLogger ()

Create or retrieve the anonymous logger. If created, the logging level is set to the default global logging level.

Returns
  • the anonymous logger

public static synchronized ILogger getLogger (String name, int level)

Create or retrieve a named logger.

Parameters
name logger name
level the cut-off level
Returns
  • the logger

public static synchronized ILogger getLogger (Class<?> clazz, int level)

Create or retrieve a logger attached to and named after a given class.

Parameters
clazz class reference
level the cut-off level
Returns
  • the logger

public static synchronized List<Sink<?>> getRegularSinks ()

Get a list of the regular (= non status) sinks.

public static synchronized List<LogStatusSink> getStatusSinks ()

Returns
  • the list of status sinks

public static synchronized boolean isGloballyDisabled (ILogger logger)

public static String levelToString (int level)

public static int parseLevel (String s)

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.

Parameters
s a log level name or integer as a string
Returns
  • integer log level, a negative value on error

public static synchronized BufferSink removeDestinationBuffer (List<CharSequence> buffer)

Remove a destination buffer.

Parameters
buffer the destination buffer
Returns
  • the sink

public static synchronized StreamSink removeDestinationStream (OutputStream out)

Remove a destination stream.

Parameters
out the destination stream
Returns
  • the sink

public static synchronized void removeGlobalFilter (String pattern)

public static synchronized void removeStatusSink (LogStatusSink sink)

Unregister a status sink.

public static synchronized void setEnabledLevel (int level)

Set the default logging level

Parameters
level the default logging level

public static synchronized void setEnabledLevel (int level, boolean updateExistingLoggers)

public static synchronized void status (String format, Object... params)

Convenience method for getLogger().status(...).