|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.camunda.commons.logging.BaseLogger
public abstract class BaseLogger
Base class for implementing a logger class. A logger class is a class with dedicated methods for each log message:
public class MyLogger extends BaseLogger {
public static MyLogger LOG = createLogger(MyLogger.class, "MYPROJ", "org.example", "01");
public void engineStarted(long currentTime) {
logInfo("100", "My super engine has started at '{}'", currentTime);
}
}
The logger can then be used in the following way:
LOG.engineStarted(System.currentTimeMilliseconds());This will print the following message:
INFO org.example - MYPROJ-01100 My super engine has started at '4234234523'
[PROJECT_CODE]-[COMPONENT_ID][MESSAGE_ID] messageExample:
MYPROJ-01100 My super engine has started at '4234234523'
| Field Summary | |
|---|---|
protected String |
componentId
the component Id of the logger. |
protected org.slf4j.Logger |
delegateLogger
the slf4j logger we delegate to |
protected String |
projectCode
the project code of the logger |
| Constructor Summary | |
|---|---|
protected |
BaseLogger()
|
| Method Summary | ||
|---|---|---|
static
|
createLogger(Class<T> loggerClass,
String projectCode,
String name,
String componentId)
Creates a new instance of the Logger. |
|
protected String |
exceptionMessage(String id,
String messageTemplate,
Object... parameters)
Prepares an exception message |
|
protected String |
formatMessageTemplate(String id,
String messageTemplate)
Formats a message template |
|
boolean |
isDebugEnabled()
|
|
boolean |
isErrorEnabled()
|
|
boolean |
isInfoEnabled()
|
|
boolean |
isWarnEnabled()
|
|
protected void |
logDebug(String id,
String messageTemplate,
Object... parameters)
Logs a 'DEBUG' message |
|
protected void |
logError(String id,
String messageTemplate,
Object... parameters)
Logs an 'ERROR' message |
|
protected void |
logInfo(String id,
String messageTemplate,
Object... parameters)
Logs an 'INFO' message |
|
protected void |
logWarn(String id,
String messageTemplate,
Object... parameters)
Logs an 'WARN' message |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.slf4j.Logger delegateLogger
protected String projectCode
protected String componentId
| Constructor Detail |
|---|
protected BaseLogger()
| Method Detail |
|---|
public static <T extends BaseLogger> T createLogger(Class<T> loggerClass,
String projectCode,
String name,
String componentId)
Logger.
loggerClass - the type of the loggerprojectCode - the unique code for a complete project.name - the name of the slf4j logger to use.componentId - the unique id of the component.
protected void logDebug(String id,
String messageTemplate,
Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parameters
protected void logInfo(String id,
String messageTemplate,
Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parameters
protected void logWarn(String id,
String messageTemplate,
Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parameters
protected void logError(String id,
String messageTemplate,
Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parameterspublic boolean isDebugEnabled()
public boolean isInfoEnabled()
public boolean isWarnEnabled()
public boolean isErrorEnabled()
protected String formatMessageTemplate(String id,
String messageTemplate)
id - the id of the messagemessageTemplate - the message template to use
protected String exceptionMessage(String id,
String messageTemplate,
Object... parameters)
id - the id of the messagemessageTemplate - the message template to useparameters - the parameters for the message (optional)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||