public final class LoggerMethods extends Object
Contains one-liners for logging operations.
The one-liners in this class make it easy to log INFO, WARNING, ALERT, TRACE, and DEBUG-level messages to Martini's underlying logging engine. The default logger used by these one-liners is named Martini.
| Modifier and Type | Method and Description |
|---|---|
static String |
debug(String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
debug(String loggerName,
String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
debugIfEnabled(String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
debugIfEnabled(String loggerName,
String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
error(String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
error(String loggerName,
String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
error(String loggerName,
String message,
Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
error(String message,
Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
errorIfEnabled(String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
errorIfEnabled(String loggerName,
String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
errorIfEnabled(String loggerName,
String message,
Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
errorIfEnabled(String message,
Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
info(String message)
Logs an INFO message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
info(String loggerName,
String message)
Logs an INFO message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
infoIfEnabled(String message)
Logs a INFO message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
infoIfEnabled(String loggerName,
String message)
Logs an INFO message to the underlying log engine of Martini,
using a logger named after
loggerName. |
ApplicationLogger |
logger()
Get a logged named groovy.
|
static ApplicationLogger |
logger(Class clazz)
Get a logger named after a class.
|
static ApplicationLogger |
logger(String scriptName)
Get a logger named after a script.
|
static String |
logTo(String message,
String scriptName)
Log a message using a logger named after
scriptName. |
static String |
print(String message)
Print a message using
System#out#print(String). |
static String |
println(String message)
Print a message using
System#out#println(String). |
static String |
trace(String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
trace(String loggerName,
String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
traceIfEnabled(String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
traceIfEnabled(String loggerName,
String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
warn(String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
warn(String loggerName,
String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named after
loggerName. |
static String |
warnIfEnabled(String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named Martini.
|
static String |
warnIfEnabled(String loggerName,
String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named after
loggerName. |
public static String print(String message)
System#out#print(String).message - the messagepublic static String println(String message)
System#out#println(String).message - the messagepublic static ApplicationLogger logger(String scriptName)
Get a logger named after a script. The logger can then be used by a script to log to Martini's underlying logging engine.
Example usage:
def logger = 'tld.organization.project.Script'.logger() logger.info( "This message will be logged at the INFO level" );
scriptName - the name of the loggerloggerpublic static ApplicationLogger logger(Class clazz)
Get a logger named after a class. The logger can then be used by a script to log to Martini's underlying logging engine.
Example usage:
def logger = getClass().logger() logger.info( "This message will be logged at the INFO level" );
clazz - the class to attach the logger tologgerpublic ApplicationLogger logger()
Get a logged named groovy. The logger can then be used by a script to log to Martini's underlying logging engine.
Example usage:
def logger = logger() logger.info( "This message will be logged at the INFO level" );
loggerpublic static String logTo(String message, String scriptName)
Log a message using a logger named after scriptName.
Example usage:
'This message will be logged at the INFO level'.logTo( 'tld.organization.project.Script' )
message - the message to logscriptName - the name of the loggerpublic static String trace(String message)
Logs a TRACE message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
'This message will be logged at the TRACE level'.trace();
message - the message to logpublic static String trace(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
'tld.organization.project.Script'.trace( 'This message will be logged at the TRACE level' )
loggerName - the name of the loggermessage - the message to logpublic static String traceIfEnabled(String message)
Logs a TRACE message to the underlying log engine of Martini, using a logger named Martini. To succeed, TRACE messages must be enabled for said logger.
Example usage:
'This message will be logged at the TRACE level'.traceIfEnabled();
public static String traceIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a TRACE message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, TRACE messages must be enabled for said logger.
Example usage:
'tld.organization.project.Script'.traceIfEnabled( 'This message will be logged at the TRACE level' )
loggerName - the name of the loggermessage - the message to logpublic static String debug(String message)
Logs a DEBUG message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
'This message will be logged at the DEBUG level'.debug();
public static String debug(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
'tld.organization.project.Script'.debug( 'This message will be logged at the DEBUG level' )
loggerName - the name of the loggermessage - the message to logpublic static String debugIfEnabled(String message)
Logs a DEBUG message to the underlying log engine of Martini, using a logger named Martini. To succeed, DEBUG messages must be enabled for said logger.
Example usage:
'This message will be logged at the DEBUG level'.debugIfEnabled();
public static String debugIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a DEBUG message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, DEBUG messages must be enabled for said logger.
Example usage:
'tld.organization.project.Script'.debugIfEnabled( 'This message will be logged at the DEBUG level' )
loggerName - the name of the loggermessage - the message to logpublic static String info(String message)
Logs an INFO message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
'This message will be logged at the INFO level'.info();
message - the message to logpublic static String info(@GloopParameter(allowNull=false) String loggerName, String message)
Logs an INFO message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
'tld.organization.project.Script'.info( 'This message will be logged at the INFO level' )
loggerName - the name of the loggermessage - the message to logpublic static String infoIfEnabled(String message)
Logs a INFO message to the underlying log engine of Martini, using a logger named Martini. To succeed, INFO messages must be enabled for said logger.
Example usage:
'This message will be logged at the INFO level'.infoIfEnabled();
message - the message to logpublic static String infoIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message)
Logs an INFO message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, INFO messages must be enabled for said logger.
Example usage:
'tld.organization.project.Script'.infoIfEnabled( 'This message will be logged at the INFO level' )
loggerName - the name of the loggermessage - the message to logpublic static String warn(String message)
Logs a WARN message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
'This message will be logged at the WARN level'.warn();
message - the message to logpublic static String warn(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
'tld.organization.project.Script'.warn( 'This message will be logged at the WARN level' )
loggerName - the name of the loggermessage - the message to logpublic static String warnIfEnabled(String message)
Logs a WARN message to the underlying log engine of Martini, using a logger named Martini. To succeed, WARN messages must be enabled for said logger.
Example usage:
'This message will be logged at the WARN level'.warnIfEnabled();
message - the message to logpublic static String warnIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message)
Logs a WARN message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, WARN messages must be enabled for said logger.
Example usage:
'tld.organization.project.Script'.warnIfEnabled( 'This message will be logged at the WARN level' )
loggerName - the name of the loggermessage - the message to logpublic static String error(String message)
Logs an ERROR message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
'This message will be logged at the ERROR level'.error();
message - the message to logpublic static String error(@GloopParameter(allowNull=false) String loggerName, String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
'tld.organization.project.Script'.error( 'This message will be logged at the ERROR level' )
loggerName - the name of the loggermessage - the message to logpublic static String error(String message, Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini, using a logger named Martini.
Example usage:
try {
...
} catch ( Exception exception ) {
'This message will be logged at the ERROR level'.error( 'Could not perform operation', exception );
}
message - the message to logthrowable - the throwable to logpublic static String error(@GloopParameter(allowNull=false) String loggerName, String message, Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after loggerName.
Example usage:
try {
...
} catch ( Exception exception ) {
'tld.organization.project.Script'.error( 'This message will be logged at the ERROR level', exception )
}
loggerName - the name of the loggermessage - the message to logthrowable - the throwable to log@GloopComment(value="Send an error message to the underlying log engine with category `Martini`, if error messages are enabled for the category") public static String errorIfEnabled(@GloopParameter(value="Message to print to log error") String message)
Logs an ERROR message to the underlying log engine of Martini, using a logger named Martini. To succeed, ERROR messages must be enabled for said logger.
Example usage:
'This message will be logged at the ERROR level'.errorIfEnabled();
message - the message to logpublic static String errorIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, ERROR messages must be enabled for said logger.
Example usage:
'tld.organization.project.Script'.errorIfEnabled( 'This message will be logged at the ERROR level' )
loggerName - the name of the loggermessage - the message to logpublic static String errorIfEnabled(String message, Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini, using a logger named Martini. To succeed, ERROR messages must be enabled for said logger.
Example usage:
try {
...
} catch ( Exception exception ) {
'This message will be logged at the ERROR level'.errorIfEnabled( exception );
}
message - the message to logthrowable - the throwable to logpublic static String errorIfEnabled(@GloopParameter(allowNull=false) String loggerName, String message, Throwable throwable)
Logs an ERROR message to the underlying log engine of Martini,
using a logger named after loggerName.
To succeed, ERROR messages must be enabled for said logger.
Example usage:
try {
...
} catch ( Exception exception ) {
'tld.organization.project.Script'.errorIfEnabled( 'This message will be logged at the ERROR level',
exception )
}
loggerName - the name of the loggermessage - the message to logthrowable - the throwable to logCopyright © 2020. All rights reserved.