Package ej.util.message.basic
Class BasicMessageLogger
- java.lang.Object
-
- ej.util.message.basic.BasicMessageLogger
-
- All Implemented Interfaces:
MessageLogger
public class BasicMessageLogger extends Object implements MessageLogger
A basic message logger delegates the messages build to aMessageBuilderand prints them to the standard output stream.- See Also:
System.out
-
-
Field Summary
Fields Modifier and Type Field Description static BasicMessageLoggerINSTANCEAn instance of BasicMessageLogger.
-
Constructor Summary
Constructors Constructor Description BasicMessageLogger()Creates an instance usingBasicMessageBuilder.INSTANCEto build the messages.BasicMessageLogger(MessageBuilder builder)Creates an instance passing the message builder used to build the messages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageBuildergetMessageBuilder()Gets the message builder used to build the messages.voidlog(char level, String category, int id)Logs a message.voidlog(char level, String category, int id, Object... arguments)Logs a message with arguments.voidlog(char level, String category, int id, Throwable t)Logs a message with a throwable.voidlog(char level, String category, int id, Throwable t, Object... arguments)Logs a message with a throwable and arguments.voidsetMessageBuilder(MessageBuilder builder)Sets the message builder used to build the messages.
-
-
-
Field Detail
-
INSTANCE
public static final BasicMessageLogger INSTANCE
An instance of BasicMessageLogger.
-
-
Constructor Detail
-
BasicMessageLogger
public BasicMessageLogger()
Creates an instance usingBasicMessageBuilder.INSTANCEto build the messages.
-
BasicMessageLogger
public BasicMessageLogger(MessageBuilder builder)
Creates an instance passing the message builder used to build the messages.- Parameters:
builder- theMessageBuilderto use, cannot benull.- Throws:
NullPointerException- if the given builder isnull.
-
-
Method Detail
-
getMessageBuilder
public MessageBuilder getMessageBuilder()
Description copied from interface:MessageLoggerGets the message builder used to build the messages.- Specified by:
getMessageBuilderin interfaceMessageLogger- Returns:
- the message builder.
-
setMessageBuilder
public void setMessageBuilder(MessageBuilder builder)
Description copied from interface:MessageLoggerSets the message builder used to build the messages.- Specified by:
setMessageBuilderin interfaceMessageLogger- Parameters:
builder- the message builder to set, cannot benull.
-
log
public void log(char level, String category, int id)Description copied from interface:MessageLoggerLogs a message.- Specified by:
login interfaceMessageLogger- Parameters:
level- the level of the message.category- the category of the message.id- the ID of the message.- See Also:
MessageBuilder.buildMessage(char, String, int)
-
log
public void log(char level, String category, int id, Throwable t)Description copied from interface:MessageLoggerLogs a message with a throwable.- Specified by:
login interfaceMessageLogger- Parameters:
level- the level of the message.category- the category of the message.id- the ID of the message.t- the throwable.- See Also:
MessageBuilder.buildMessage(char, String, int, Throwable)
-
log
public void log(char level, String category, int id, Object... arguments)Description copied from interface:MessageLoggerLogs a message with arguments.- Specified by:
login interfaceMessageLogger- Parameters:
level- the level of the message.category- the category of the message.id- the ID of the message.arguments- the arguments.- See Also:
MessageBuilder.buildMessage(char, String, int, Object...)
-
log
public void log(char level, String category, int id, Throwable t, Object... arguments)Description copied from interface:MessageLoggerLogs a message with a throwable and arguments.- Specified by:
login interfaceMessageLogger- Parameters:
level- the level of the message.category- the category of the message.id- the ID of the message.t- the throwable.arguments- the arguments.- See Also:
MessageBuilder.buildMessage(char, String, int, Throwable, Object...)
-
-