Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.compoze.collab.log
Class Logger

    java.lang.Object
      com.compoze.collab.log.Logger

public class Logger
extends java.lang.Object

This is the main class that clients use to do logging. Implementing logging using this class consists of the following:

- create `EntryPrototype` instances for each log message
- create a properties file that contains the default translated resources for the entry prototypes
- add any `ILogListener` implementations to receive log events
- get a `Logger` instance using `Logger.createLogger()`
- call the `Logger.log()` methods with your prototypes and arguments to create log entries

Method Summary
`static void` | `addDefaultListener(ILogListener listener)` Adds a default log listener (immediately affects every `Logger` that has not changed its listeners from the default).
`void` | `addListener(ILogListener listener)` Adds a listener to this logger.
`static Logger` | `createLogger(java.lang.String sName, ILogContext logContext, com.compoze.collab.resource.ResourceBundleCache bundle, Logger parent)` Creates a named logger that pulls its logging context from the specified object.
`static Logger` | `createLogger(java.lang.String sName, ILogContext logContext, java.lang.String sResourceBaseName, Logger parent)` Creates a named logger that pulls its logging context from the specified object.
`static java.util.List` | `getDefaultListeners()` Gets the default log listeners.
`static LogLevel` | `getDefaultLogLevel()` Gets the default log level.
`java.util.List` | `getListeners()` Gets the log listeners registered for this logger.
`LogLevel` | `getLogLevel()` Gets the log level.
`java.io.PrintWriter` | `getLogWriter(LogLevel level)` Gets a `PrintWriter` which will write a log entry for each line that is written to the writer (`println` should be used to write a line).
`java.lang.String` | `getName()` Gets the name of the logger.
`boolean` | `isLogEnabled(LogEntryPrototype prototype)` Determines if logging is enabled for a prototype.
`void` | `log(LogEntryPrototype prototype)` Logs a message.
`void` | `log(LogEntryPrototype prototype, java.lang.Object arg)` Logs an event.
`void` | `log(LogEntryPrototype prototype, java.lang.Object[] args)` Logs an event.
`void` | `log(LogLevel level, java.lang.String s)` Logs a single `String` argument using a default log entry prototype.
`void` | `log(java.lang.Throwable t, LogEntryPrototype prototype)` Logs an event.
`void` | `log(java.lang.Throwable t, LogEntryPrototype prototype, java.lang.Object arg)` Logs an event.
`void` | `log(java.lang.Throwable t, LogEntryPrototype prototype, java.lang.Object[] args)` Logs an event.
`static boolean` | `removeDefaultListener(ILogListener listener)` Removes a default log listener (immediately affects every `Logger` that has not changed its listeners from the default).
`boolean` | `removeListener(ILogListener listener)` Removes a listener from this logger.
`static void` | `setDefaultLogLevel(LogLevel level)` Sets the default log level.
`void` | `setLogLevel(LogLevel level)` Sets the log level (everything this level and more severe is logged).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setDefaultLogLevel

    public static void setDefaultLogLevel(LogLevel level)

  Sets the default log level. For those loggers on which `setLogLevel` has not already been called, this is the level that is used. When the default log level is changed, all loggers using the default log level will change to the new level immediately.

  Parameters:
    `level` - the default log level (not `null`)

### getDefaultLogLevel

    public static LogLevel getDefaultLogLevel()

  Gets the default log level.

  Returns:
    the default log level (not `null`)

### getName

    public java.lang.String getName()

  Gets the name of the logger.

  Returns:
    the name of the logger

### setLogLevel

    public void setLogLevel(LogLevel level)

  Sets the log level (everything this level and more severe is logged).

  Parameters:
    `level` - the log level (not `null`)

### getLogLevel

    public LogLevel getLogLevel()

  Gets the log level. If `(LogLevel)` has never been called, this returns the default log level.

  Returns:
    the log level

### isLogEnabled

    public boolean isLogEnabled(LogEntryPrototype prototype)

  Determines if logging is enabled for a prototype. It's important to use this method before logging messages that can take a long time to instantiate. The `log` method itself will re-check whether or not logging is enabled for a particular message, but the check itself takes little time compared to how long it can take to instantiate a log message.

  Parameters:
    `prototype` - the log entry prototype
  Returns:
    `true` if logging is enabled for the prototype

### getLogWriter

    public java.io.PrintWriter getLogWriter(LogLevel level)

  Gets a `PrintWriter` which will write a log entry for each line that is written to the writer (`println` should be used to write a line).

  Parameters:
    `level` - the log level

### log

    public void log(LogLevel level,
                    java.lang.String s)

  Logs a single `String` argument using a default log entry prototype. Using an explicit log entry prototype is preferred because it can be properly internationalized, but this may be useful for debug or tracing info that does not contain locale specific text.

### log

    public void log(LogEntryPrototype prototype)

  Logs a message.

  Parameters:
    `prototype` - the log entry prototype

### log

    public void log(LogEntryPrototype prototype,
                    java.lang.Object arg)

  Logs an event.

  Parameters:
    `prototype` - the log entry prototype
    `arg` - an argument for the log entry message (or `null` if there are no arguments)

### log

    public void log(LogEntryPrototype prototype,
                    java.lang.Object[] args)

  Logs an event.

  Parameters:
    `prototype` - the log entry prototype
    `args` - arguments for the log entry message (or `null` if there are no arguments)

### log

    public void log(java.lang.Throwable t,
                    LogEntryPrototype prototype)

  Logs an event.

  Parameters:
    `t` - the throwable to log
    `prototype` - the log entry prototype

### log

    public void log(java.lang.Throwable t,
                    LogEntryPrototype prototype,
                    java.lang.Object arg)

  Logs an event.

  Parameters:
    `t` - the throwable to log
    `prototype` - the log entry prototype
    `arg` - argument for the log entry message (or `null` if there are no arguments)

### log

    public void log(java.lang.Throwable t,
                    LogEntryPrototype prototype,
                    java.lang.Object[] args)

  Logs an event.

  Parameters:
    `t` - the throwable to log
    `prototype` - the log entry prototype
    `args` - arguments for the log entry message (or `null` if there are no arguments)

### getDefaultListeners

    public static java.util.List getDefaultListeners()

  Gets the default log listeners.

  Returns:
    an unmodifiable list of `ILogListener` instances that are the defaults for all loggers that have not changed their listeners

### addDefaultListener

    public static void addDefaultListener(ILogListener listener)

  Adds a default log listener (immediately affects every `Logger` that has not changed its listeners from the default).

  Parameters:
    `listener` - the listener to add (not `null`)

### removeDefaultListener

    public static boolean removeDefaultListener(ILogListener listener)

  Removes a default log listener (immediately affects every `Logger` that has not changed its listeners from the default).

  Parameters:
    `listener` - the listener to remove
  Returns:
    `true` if the listener was removed, `false` if the specified listener was not a default

### addListener

    public void addListener(ILogListener listener)

  Adds a listener to this logger. If this is the first time a listener has been added to this logger, the default listeners are first copied into the list.

  Parameters:
    `listener` - the listener to add (not `null`)

### removeListener

    public boolean removeListener(ILogListener listener)

  Removes a listener from this logger. If this is the first time a listener has been removed from the logger, the default listeners are first copied into the list.

  Parameters:
    `listener` - the listener to remove (not `null`)
  Returns:
    `true` if the listener was removed, `false` if the specified listener was not registered for this logger

### getListeners

    public java.util.List getListeners()

  Gets the log listeners registered for this logger.

  Returns:
    an unmodifiable list of `ILogListener` instances that are currently registered

### createLogger

    public static Logger createLogger(java.lang.String sName,
                                      ILogContext logContext,
                                      java.lang.String sResourceBaseName,
                                      Logger parent)

  Creates a named logger that pulls its logging context from the specified object.

  Parameters:
    `sName` - the name of the logger
    `logContext` - the log context
    `sResourceBaseName` - the base name of the resource bundle
    `parent` - the parent logger to consult for resources (may be `null` if not parent exists for the new logger)
  Returns:
    the newly created logger

### createLogger

    public static Logger createLogger(java.lang.String sName,
                                      ILogContext logContext,
                                      com.compoze.collab.resource.ResourceBundleCache bundle,
                                      Logger parent)

  Creates a named logger that pulls its logging context from the specified object.

  Parameters:
    `sName` - the name of the logger
    `logContext` - the log context
    `bundle` - the resource bundle cache
    `parent` - the parent logger to consult for resources (may be `null` if not parent exists for the new logger)
  Returns:
    the newly created logger

Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.