com.google.gwt.libideas.logging.shared
Class Log

java.lang.Object
  extended by com.google.gwt.libideas.logging.shared.Log
Direct Known Subclasses:
ServerLogManager

public class Log
extends java.lang.Object

This class is very loosely based Java's Logger class. It is static to allow differed binding to remove logging information in production code. By default the logging level is set to Level.CONFIG. If you wish to use this class in code that may not be run in a GWT environment, you must instantiate on of the system logging adaptors available from com.google.gwt.libideas.logging.server.SystemLogSystemLog.


Field Summary
static java.lang.String CATEGORY
           
 
Constructor Summary
Log()
           
 
Method Summary
static boolean addLogHandler(LogHandler handler)
          Add a log Handler to receive logging messages.
static void clearLogHandlers()
          Clear all handlers.
static void config(java.lang.String msg)
          Log a CONFIG message.
static void config(java.lang.String msg, java.lang.String category)
          Log a CONFIG message.
static void fine(java.lang.String msg)
          Log a FINE message.
static void fine(java.lang.String msg, java.lang.String category)
          Log a FINE message.
static void finer(java.lang.String msg)
          Log a FINER message.
static void finer(java.lang.String msg, java.lang.String category)
          Log a FINER message.
static void finest(java.lang.String msg)
          Log a FINEST message.
static void finest(java.lang.String msg, java.lang.String category)
          Log a FINEST message.
static Level getDefaultLevel()
          Get the default log level needed to publish messages.
protected static com.google.gwt.libideas.logging.shared.impl.LogImpl getLogImpl()
          Gets the current LogImpl class.
static void info(java.lang.String msg)
          Log an INFO message.
static void info(java.lang.String msg, java.lang.String category)
          Log an INFO message.
protected static void initLogImpl(com.google.gwt.libideas.logging.shared.impl.LogImpl impl)
           
static boolean isLoggable(Level level)
          Check if a message of the given level would actually be logged by this logger.
static boolean isLoggingMinimal()
          Is the logging system in minimal mode? i.e.
static boolean isLoggingSupported()
          Is Logging supported?
static java.util.Iterator levelIterator()
          Returns an iterator of all currently defined levels.
static void log(java.lang.String msg, Level level, java.lang.String category, java.lang.Throwable e)
          Logs a message using a given level.
static Level parseLevel(java.lang.String levelName)
          Return the correct level based on name.
static void removeLogHandler(LogHandler handler)
          Remove a log Handler.
static void setDefaultLevel(Level newLevel)
          Set the default log level specifying which message levels will be logged by this logger.
static void setLevel(java.lang.String category, Level level)
          Sets the level of a given logging category.
static void severe(java.lang.String msg)
          Log a SEVERE message.
static void severe(java.lang.String msg, java.lang.String category)
          Log a SEVERE message.
static void severe(java.lang.String msg, java.lang.String category, java.lang.Throwable t)
          Log a SEVERE message.
static java.lang.String[] splitCategory(java.lang.String category)
          Splits the category into its component parts, separated by the "." character.
static void warning(java.lang.String msg)
          Log a WARNING message.
static void warning(java.lang.String msg, java.lang.String category)
          Log a WARNING message.
static void warning(java.lang.String msg, java.lang.String category, java.lang.Throwable e)
          Log a WARNING message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CATEGORY

public static final java.lang.String CATEGORY
See Also:
Constant Field Values
Constructor Detail

Log

public Log()
Method Detail

addLogHandler

public static boolean addLogHandler(LogHandler handler)
Add a log Handler to receive logging messages.

If no handlers are supplied and a message should be logged, it will be logging to the GWT console in hosted mode and the JavaScript console in web mode.

Parameters:
handler - the new handler
Returns:
whether the handler was added.

clearLogHandlers

public static void clearLogHandlers()
Clear all handlers.


config

public static void config(java.lang.String msg)
Log a CONFIG message.


config

public static void config(java.lang.String msg,
                          java.lang.String category)
Log a CONFIG message.


fine

public static void fine(java.lang.String msg)
Log a FINE message.


fine

public static void fine(java.lang.String msg,
                        java.lang.String category)
Log a FINE message.


finer

public static void finer(java.lang.String msg)
Log a FINER message.


finer

public static void finer(java.lang.String msg,
                         java.lang.String category)
Log a FINER message.


finest

public static void finest(java.lang.String msg)
Log a FINEST message.


finest

public static void finest(java.lang.String msg,
                          java.lang.String category)
Log a FINEST message.


getDefaultLevel

public static Level getDefaultLevel()
Get the default log level needed to publish messages. This can be overridden by the settings per category.

Returns:
this Logger's level

info

public static void info(java.lang.String msg)
Log an INFO message.


info

public static void info(java.lang.String msg,
                        java.lang.String category)
Log an INFO message.


isLoggable

public static boolean isLoggable(Level level)
Check if a message of the given level would actually be logged by this logger. This check is based on the Loggers effective level, which may be inherited from its parent.

Parameters:
level - a message logging level
Returns:
true if the given message level is currently being logged.

isLoggingMinimal

public static boolean isLoggingMinimal()
Is the logging system in minimal mode? i.e. only severe logging messages are logged and


isLoggingSupported

public static boolean isLoggingSupported()
Is Logging supported?


levelIterator

public static java.util.Iterator levelIterator()
Returns an iterator of all currently defined levels.


log

public static void log(java.lang.String msg,
                       Level level,
                       java.lang.String category,
                       java.lang.Throwable e)
Logs a message using a given level. This method cannot be removed in minimal logging mode, so use it only if you cannot use one of the static logging messages.


parseLevel

public static Level parseLevel(java.lang.String levelName)
Return the correct level based on name.

Throws:
java.lang.IllegalArgumentException - for unknown levels.

removeLogHandler

public static void removeLogHandler(LogHandler handler)
Remove a log Handler.

Returns silently if the given Handler is not found or is null

Parameters:
handler - a logging Handler
Throws:
java.lang.SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").

setDefaultLevel

public static void setDefaultLevel(Level newLevel)
Set the default log level specifying which message levels will be logged by this logger.


setLevel

public static void setLevel(java.lang.String category,
                            Level level)
Sets the level of a given logging category. This level overrides the default logging level.

Parameters:
category - category
level - level

severe

public static void severe(java.lang.String msg)
Log a SEVERE message.

If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message

severe

public static void severe(java.lang.String msg,
                          java.lang.String category)
Log a SEVERE message.


severe

public static void severe(java.lang.String msg,
                          java.lang.String category,
                          java.lang.Throwable t)
Log a SEVERE message.


splitCategory

public static java.lang.String[] splitCategory(java.lang.String category)
Splits the category into its component parts, separated by the "." character.


warning

public static void warning(java.lang.String msg)
Log a WARNING message.

If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message

warning

public static void warning(java.lang.String msg,
                           java.lang.String category)
Log a WARNING message.


warning

public static void warning(java.lang.String msg,
                           java.lang.String category,
                           java.lang.Throwable e)
Log a WARNING message.


getLogImpl

protected static com.google.gwt.libideas.logging.shared.impl.LogImpl getLogImpl()
Gets the current LogImpl class. Should only be used by classes directly extending the logging system.


initLogImpl

protected static void initLogImpl(com.google.gwt.libideas.logging.shared.impl.LogImpl impl)