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
FieldsModifier and TypeFieldDescriptionstatic final DurationThe default logging frequency for status messages. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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 voidWrites an informational (Level.INFO) log message if the algorithm has logging enabled.voidWrites a log message using this extension.static voidWrites a log message if the algorithm has logging enabled.voidonRegister(Algorithm algorithm) Called when this extension is registered with an algorithm.voidCalled after each step of the algorithm.voidonTerminate(Algorithm algorithm) Called after the termination of an algorithm.static voidWrites a severe (Level.SEVERE) log message if the algorithm has logging enabled.static voidWrites 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, waitMethods inherited from interface org.moeaframework.algorithm.extension.Extension
onInitialize, onRun
-
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 messages
-
-
Method Details
-
onStep
Description copied from interface:ExtensionCalled after each step of the algorithm. -
onRegister
Description copied from interface:ExtensionCalled when this extension is registered with an algorithm. This can be used to perform any type checking or initialization.- Specified by:
onRegisterin interfaceExtension- Parameters:
algorithm- the algorithm associated with this extension
-
onTerminate
Description copied from interface:ExtensionCalled after the termination of an algorithm.- Specified by:
onTerminatein 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
-