Class LoggingExtension
java.lang.Object
org.moeaframework.algorithm.extension.LoggingExtension
- All Implemented Interfaces:
Extension
Extension that logs information about the execution, including the current NFE and elapsed time. Furthermore, the
static methods can be used to write log messages if the algorithm has logging enabled.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Duration
The default logging frequency for status messages. -
Constructor Summary
ConstructorDescriptionConstructs a new, default logging extension.LoggingExtension
(String name) Constructs a new logger with the given name.LoggingExtension
(String name, Duration logFrequency) Constructs a new logger with the given name and settings.LoggingExtension
(Logger logger, Duration logFrequency) Constructs a new logger with the given name and settings. -
Method Summary
Modifier and TypeMethodDescriptionReturns the logger used by this extension.static void
Writes an informational (Level.INFO
) log message if the algorithm has logging enabled.void
Writes a log message using this extension.static void
Writes a log message if the algorithm has logging enabled.void
onRegister
(Algorithm algorithm) Called when this extension is registered with an algorithm.void
Called after each step of the algorithm.void
onTerminate
(Algorithm algorithm) Called after the termination of an algorithm.static void
Writes a severe (Level.SEVERE
) log message if the algorithm has logging enabled.static void
Writes a warning (Level.WARNING
) log message if the algorithm has logging enabled.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.algorithm.extension.Extension
onInitialize
-
Field Details
-
DEFAULT_LOG_FREQUENCY
The default logging frequency for status messages.
-
-
Constructor Details
-
LoggingExtension
public LoggingExtension()Constructs a new, default logging extension. -
LoggingExtension
Constructs a new logger with the given name.- Parameters:
name
- the logger name
-
LoggingExtension
Constructs a new logger with the given name and settings.- Parameters:
name
- the logger namelogFrequency
- the frequency to print log messages
-
LoggingExtension
Constructs a new logger with the given name and settings.- Parameters:
logger
- the loggerlogFrequency
- the frequency to print log messagesfrequencyType
- the type of frequency
-
-
Method Details
-
onStep
Description copied from interface:Extension
Called after each step of the algorithm. -
onRegister
Description copied from interface:Extension
Called when this extension is registered with an algorithm. This can be used to perform any type checking or initialization.- Specified by:
onRegister
in interfaceExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
onTerminate
Description copied from interface:Extension
Called after the termination of an algorithm.- Specified by:
onTerminate
in interfaceExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
getLogger
Returns the logger used by this extension.- Returns:
- the logger
-
log
Writes a log message using this extension.- Parameters:
level
- the log levelmessage
- the log messageparams
- additional parameters used to format the log message
-
info
Writes an informational (Level.INFO
) log message if the algorithm has logging enabled.- Parameters:
algorithm
- the algorithmmessage
- the log messageparams
- additional parameters used to format the log message
-
warning
Writes a warning (Level.WARNING
) log message if the algorithm has logging enabled.- Parameters:
algorithm
- the algorithmmessage
- the log messageparams
- additional parameters used to format the log message
-
severe
Writes a severe (Level.SEVERE
) log message if the algorithm has logging enabled.- Parameters:
algorithm
- the algorithmmessage
- the log messageparams
- additional parameters used to format the log message
-
log
Writes a log message if the algorithm has logging enabled.- Parameters:
algorithm
- the algorithmlevel
- the log levelmessage
- the log messageparams
- additional parameters used to format the log message
-