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_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

Constants

public static final int LEVEL_ALL

Constant Value: 0 (0x00000000)

public static final int LEVEL_ALWAYS_ON

Constant Value: 60 (0x0000003c)

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_INTERNAL

Reserved for internal use

Constant Value: 19 (0x00000013)

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)

Fields

public static final List<String> LEVEL_NAMES

public static final int STANDARD_CUTOFF_LEVEL

public static boolean prefixWithLevel

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

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 int getLevelFromPrefixLetter (char ch)

Retrieve the log level associated to the provided prefix letter.

Parameters
ch prefix letter
Returns
  • log level matching the prefix character; negative value on error

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 char getPrefixLetterForLevel (int level)

Retrieve the prefix letter associated to the provided log level.

Parameters
level log level
Returns
  • a letter describing the level; 0 on failure

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 int setCutoffLevel (int cutoffLevel)

Parameters
cutoffLevel new level
Returns
  • the previous level

public static synchronized void setGlobalFilter (boolean mute)

public static int setLevelForNewLoggers (int level)

Set the default logging level

Parameters
level the default logging level

public static synchronized int setLevelForNewLoggers (int level, boolean updateExistingLoggers)

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

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