org.ogf.graap.wsag.api.logging
Class LogMessage

java.lang.Object
  extended by org.ogf.graap.wsag.api.logging.LogMessage

public class LogMessage
extends Object

A simple log message that can be used in conjunction with Log4J in order to improve logging speed. A LogMessage takes a message and a number of arguments that are formated with MessageFormat on demand, i.e. the rendering of the resulting message will only take place if the message is really logged by the Log4J framework, i.e. the log level is set accordingly.

Author:
owaeld

Constructor Summary
LogMessage(String message, Object... params)
          Creates a new log message.
 
Method Summary
static String format(String message, Object... params)
          Formats a log message to a string.
static LogMessage getMessage(String message, Object... params)
          Creates a new log message.
 String toString()
          Renders the message when required by Log4J, i.e. the message is finally printed to the log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogMessage

public LogMessage(String message,
                  Object... params)
Creates a new log message.

Parameters:
message - the message pattern
params - the message parameters
See Also:
MessageFormat.format(String, Object...)
Method Detail

getMessage

public static LogMessage getMessage(String message,
                                    Object... params)
Creates a new log message.

Parameters:
message - the message pattern
params - the message parameters
Returns:
the new LogEntry
See Also:
MessageFormat.format(String, Object...)

format

public static String format(String message,
                            Object... params)
Formats a log message to a string.

Parameters:
message - the message pattern
params - the message parameters
Returns:
the new formated message
See Also:
MessageFormat.format(String, Object...)

toString

public String toString()
Renders the message when required by Log4J, i.e. the message is finally printed to the log.

Overrides:
toString in class Object
Returns:
the rendered message


Copyright © 2008-2012. All Rights Reserved.