# Class: 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](ILogger) instances returned by [#getLogger()](#getLogger()) are not thread\-safe. 

 How to use: 

```

 import com.pnfsoftware.jeb.util.logging.ILogger;
 import com.pnfsoftware.jeb.util.logging.GlobalLog;

 class Xyz {
     private static final ILogger logger = GlobalLog.getLogger(Xyz.class);
     ...
 }
 
```

## Constructor: GlobalLog


## Static Field: LEVEL_ALL
Type: `int`

Constant value: `0`
Description: Log level allowing all messages.

## Static Field: LEVEL_ALWAYS_ON
Type: `int`

Constant value: `60`
Description: Threshold for messages that bypass regular level filtering.

## Static Field: LEVEL_CATCHING
Type: `int`

Constant value: `60`
Description: 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.

## Static Field: LEVEL_DEBUG
Type: `int`

Constant value: `20`
Description: Debug log level.

## Static Field: LEVEL_DISABLED
Type: `int`

Constant value: `2147483647`
Description: Log level disabling regular messages.

## Static Field: LEVEL_ERROR
Type: `int`

Constant value: `50`
Description: Error log level.

## Static Field: LEVEL_INFO
Type: `int`

Constant value: `30`
Description: Information log level.

## Static Field: LEVEL_INTERNAL
Type: `int`

Constant value: `19`
Description: Reserved for internal use

## Static Field: LEVEL_NAMES
Type: `java.util.List<java.lang.String>`
Description: Log level names, ordered from least to most severe regular level.

## Static Field: LEVEL_STATUS
Type: `int`

Constant value: `100`
Description: special log level indicating a status message; logs with that status will not be directed to the regular sinks

## Static Field: LEVEL_TRACE
Type: `int`

Constant value: `10`
Description: Trace log level.

## Static Field: LEVEL_WARN
Type: `int`

Constant value: `40`
Description: Warning log level.

## Static Field: STANDARD_CUTOFF_LEVEL
Type: `int`
Description: Standard global cutoff level for the current build type.

## Static Field: prefixWithLevel
Type: `boolean`
Description: True to prefix regular log messages with their level letter.

## Static Method: addDestinationBuffer
- parameter: `buffer`, type: `java.util.List<java.lang.CharSequence>`
- return type: `com.pnfsoftware.jeb.util.logging.BufferSink`

Description: 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\(\)
parameter: buffer: the thread\-safe buffer
return: the sink

## Static Method: addDestinationStream
- parameter: `out`, type: `java.io.OutputStream`
- return type: `com.pnfsoftware.jeb.util.logging.StreamSink`

Description: Add a destination stream to the list of log message recipients.
parameter: out: a destination stream
return: the sink

## Static Method: addGlobalFilter
- parameter: `pattern`, type: `java.lang.String`
- parameter: `requiredLevel`, type: `int`

Description: Add or replace a global filter.
parameter: pattern: logger name or package prefix to filter; empty string matches all loggers
parameter: requiredLevel: minimum level required for matching loggers

## Static Method: addStatusSink
- parameter: `sink`, type: `com.pnfsoftware.jeb.util.logging.LogStatusSink`

Description: Register a status sink. Those sinks receive only logs having the special level [GlobalLog#LEVEL_STATUS](GlobalLog#LEVEL_STATUS).
parameter: sink: status sink to add

## Static Method: catching
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- parameter: `t`, type: `java.lang.Throwable`

Description: Log an exception's stack trace.
parameter: logger: destination logger
parameter: t: throwable to log

## Static Method: catching
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- parameter: `t`, type: `java.lang.Throwable`
- parameter: `message`, type: `java.lang.String`

Description: Log an exception's stack trace with an optional message.
parameter: logger: destination logger
parameter: t: throwable to log
parameter: message: optional message prefix

## Static Method: catchingDebug
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- parameter: `t`, type: `java.lang.Throwable`

Description: Log an exception's stack trace at debug level.
parameter: logger: destination logger
parameter: t: throwable to log

## Static Method: catchingDebug
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- parameter: `t`, type: `java.lang.Throwable`
- parameter: `message`, type: `java.lang.String`

Description: Log an exception's stack trace at debug level with an optional message.
parameter: logger: destination logger
parameter: t: throwable to log
parameter: message: optional message prefix

## Static Method: clearGlobalFilters

Description: Remove all global filters.

## Static Method: getCutoffLevel
- return type: `int`

Description: Get the global cutoff level.
return: the global cutoff level

## Static Method: getDestinationBuffers
- return type: `java.util.List<com.pnfsoftware.jeb.util.logging.BufferSink>`

Description: Get the list of registered buffer sinks.
return: the list of buffer sinks

## Static Method: getDestinationStreams
- return type: `java.util.List<com.pnfsoftware.jeb.util.logging.StreamSink>`

Description: Get the list of registered stream sinks.
return: the list of stream sinks

## Static Method: getEnabledLevel
- return type: `int`

Description: Get the default logging level.
return: the default logging level

## Static Method: getInternalLogger
- parameter: `clazz`, type: `java.lang.Class<?>`
- return type: `com.pnfsoftware.jeb.util.logging.ILogger`

Description: Create or retrieve an internal logger. INTERNAL USAGE ONLY.
parameter: clazz: class reference
return: the internal logger

## Static Method: getLevelFromPrefixLetter
- parameter: `ch`, type: `char`
- return type: `int`

Description: Retrieve the log level associated to the provided prefix letter.
parameter: ch: prefix letter
return: log level matching the prefix character; negative value on error

## Static Method: getLogger
- return type: `com.pnfsoftware.jeb.util.logging.ILogger`

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

## Static Method: getLogger
- parameter: `clazz`, type: `java.lang.Class<?>`
- return type: `com.pnfsoftware.jeb.util.logging.ILogger`

Description: 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.
parameter: clazz: class reference
return: the logger

## Static Method: getLogger
- parameter: `clazz`, type: `java.lang.Class<?>`
- parameter: `level`, type: `int`
- return type: `com.pnfsoftware.jeb.util.logging.ILogger`

Description: Create or retrieve a logger attached to and named after a given class.
parameter: clazz: class reference
parameter: level: the cut\-off level
return: the logger

## Static Method: getLogger
- parameter: `name`, type: `java.lang.String`
- parameter: `level`, type: `int`
- return type: `com.pnfsoftware.jeb.util.logging.ILogger`

Description: Create or retrieve a named logger.
parameter: name: logger name
parameter: level: the cut\-off level
return: the logger

## Static Method: getPrefixLetterForLevel
- parameter: `level`, type: `int`
- return type: `char`

Description: Retrieve the prefix letter associated to the provided log level.
parameter: level: log level
return: a letter describing the level; 0 on failure

## Static Method: getRegularSinks
- return type: `java.util.List<com.pnfsoftware.jeb.util.logging.Sink<?>>`

Description: Get a list of the regular \(= non status\) sinks.
return: a new list containing all regular sinks

## Static Method: getStatusSinks
- return type: `java.util.List<com.pnfsoftware.jeb.util.logging.LogStatusSink>`

Description: Get the registered status sinks.
return: the list of status sinks

## Static Method: isFilteredOut
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- parameter: `messageLevel`, type: `int`
- return type: `boolean`

Description: Determine whether a message at a given level sent to a logger should be processed or ignored, based on [global filters](#addGlobalFilter(String, int)).
parameter: logger: the logger
parameter: messageLevel: the level of the message we want to verify
return: true if the message should be ignored

## Static Method: isGloballyDisabled
- parameter: `logger`, type: `com.pnfsoftware.jeb.util.logging.ILogger`
- return type: `boolean`

Description: 
deprecated: use [#isFilteredOut(ILogger, int)](#isFilteredOut(ILogger, int)) instead

## Static Method: levelToString
- parameter: `level`, type: `int`
- return type: `java.lang.String`

Description: Convert a log level to a display string.
parameter: level: log level
return: a level name

## Static Method: parseLevel
- parameter: `s`, type: `java.lang.String`
- return type: `int`

Description: 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 values are illegal log levels.
parameter: s: a log level name or integer as a string
return: integer log level, a negative value on error

## Static Method: removeDestinationBuffer
- parameter: `buffer`, type: `java.util.List<java.lang.CharSequence>`
- return type: `com.pnfsoftware.jeb.util.logging.BufferSink`

Description: Remove a destination buffer.
parameter: buffer: the destination buffer
return: the sink

## Static Method: removeDestinationStream
- parameter: `out`, type: `java.io.OutputStream`
- return type: `com.pnfsoftware.jeb.util.logging.StreamSink`

Description: Remove a destination stream.
parameter: out: the destination stream
return: the sink

## Static Method: removeGlobalFilter
- parameter: `pattern`, type: `java.lang.String`

Description: Remove a global filter.
parameter: pattern: logger name or package prefix

## Static Method: removeStatusSink
- parameter: `sink`, type: `com.pnfsoftware.jeb.util.logging.LogStatusSink`

Description: Unregister a status sink.
parameter: sink: status sink to remove

## Static Method: setCutoffLevel
- parameter: `cutoffLevel`, type: `int`
- return type: `int`

Description: Set the global cutoff level.
parameter: cutoffLevel: new level
return: the previous level

## Static Method: setGlobalFilter
- parameter: `mute`, type: `boolean`

Description: Enable or disable a global mute filter.
parameter: mute: true to mute all regular loggers

## Static Method: setLevelForNewLoggers
- parameter: `level`, type: `int`
- return type: `int`

Description: Set the default logging level.
parameter: level: the default logging level
return: the previous default logging level

## Static Method: setLevelForNewLoggers
- parameter: `level`, type: `int`
- parameter: `updateExistingLoggers`, type: `boolean`
- return type: `int`

Description: Set the default logging level for newly created loggers.
parameter: level: the default logging level
parameter: updateExistingLoggers: true to update already\-created loggers as well
return: the previous default logging level

## Static Method: status
- parameter: `format`, type: `java.lang.String`
- parameter: `params`, type: `java.lang.Object[]`

Description: Convenience method for `getLogger().status(...)`.
parameter: format: format string if parameters are provided, else standard string
parameter: params: parameters

