Package com.codingchili.core.logging
Class AbstractLogger
java.lang.Object
java.util.logging.Handler
com.codingchili.core.logging.AbstractLogger
- All Implemented Interfaces:
JsonLogger
,Logger
- Direct Known Subclasses:
ConsoleLogger
,RemoteLogger
Default logging implementation.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractLogger(CoreContext context, Class aClass)
AbstractLogger(Class aClass)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shuts down the logger instance, frees any resources such as files or thread pools.Creates a logging event using the loggers level.Creates a logging event using a provided logger level.void
flush()
log(io.vertx.core.json.JsonObject json)
void
Emit when multiple attempts to initialize singleton.void
onCacheCleared(String component)
Emit when the cache of a component has been cleared.void
onConfigurationDefaultsLoaded(String path, Class<?> clazz)
Emit when a configuration was not found on disk and its defaults was loaded from memory.void
Log general errors.void
onFileLoaded(String path)
Emit when a file has been loaded from the file-system.void
onFileLoadError(String fileName)
Emit when failing to load specified fileName;void
onFileSaved(String saver, String path)
Emit when a file has been saved to file.void
onFileSaveError(String fileName)
Emit when error to save file.void
onHandlerMissing(String target, String route)
Throw when a requested handler was not found.void
onInvalidConfigurable(Class<?> clazz)
Throw when a configuration was not found and the attempt to instantiate default configuration from the given class has error.void
onListenerStarted(CoreListener listener)
called when a listener is started.void
onListenerStopped(CoreListener listener)
called when a listener is stopped.void
onMetricsSnapshot(io.vertx.core.json.JsonObject metrics)
Send METRICS_ENABLED to the logger.void
onSecurityDependencyMissing(String target, String identifier)
Emit when a property in the security configuration is misconfigured.void
onServiceFailed(Throwable cause)
void
onServiceStarted(CoreService service)
Emit when a new server has started.void
onServiceStopped(CoreService service)
Emit when a server has stopped.void
onTimerSourceChanged(String name, int initialTimeout, int newTimeout)
Emit when the interval of a periodic timer has changed.void
removeMetadata(String nameOrKey)
setMetadata(String name, Supplier<io.vertx.core.json.JsonObject> value)
Sets a metadata value on the logger.setMetadataValue(String key, Supplier<String> value)
Sets a metadata value on the logger.Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
metadata
-
context
-
logger
-
aClass
-
-
Constructor Details
-
AbstractLogger
-
AbstractLogger
-
-
Method Details
-
log
- Specified by:
log
in interfaceJsonLogger
- Parameters:
json
- the data to be logged.- Returns:
- fluent
-
setMetadata
Description copied from interface:Logger
Sets a metadata value on the logger.- Specified by:
setMetadata
in interfaceLogger
- Parameters:
name
- a supplier to a metadata object that will be merged into the root node when an event is created..value
- the dynamic metadata to add to log events.- Returns:
- fluent.
-
setMetadataValue
Description copied from interface:Logger
Sets a metadata value on the logger.- Specified by:
setMetadataValue
in interfaceLogger
- Parameters:
key
- the key to put the metadata value in.value
- a supplier invoked when an event is created.- Returns:
- fluent.
-
removeMetadata
- Specified by:
removeMetadata
in interfaceLogger
- Parameters:
nameOrKey
- removes metadata with a matching name or key.- Returns:
- fluent.
-
event
Description copied from interface:Logger
Creates a logging event using the loggers level. -
event
Description copied from interface:Logger
Creates a logging event using a provided logger level. -
onAlreadyInitialized
public void onAlreadyInitialized()Description copied from interface:Logger
Emit when multiple attempts to initialize singleton.- Specified by:
onAlreadyInitialized
in interfaceLogger
-
onServiceStarted
Description copied from interface:Logger
Emit when a new server has started.- Specified by:
onServiceStarted
in interfaceLogger
- Parameters:
service
- the service that was started
-
onServiceStopped
Description copied from interface:Logger
Emit when a server has stopped.- Specified by:
onServiceStopped
in interfaceLogger
- Parameters:
service
- the service that was stopped
-
onListenerStarted
Description copied from interface:Logger
called when a listener is started.- Specified by:
onListenerStarted
in interfaceLogger
- Parameters:
listener
- the listener that was started
-
onListenerStopped
Description copied from interface:Logger
called when a listener is stopped.- Specified by:
onListenerStopped
in interfaceLogger
- Parameters:
listener
- the listener that was stopped
-
onServiceFailed
- Specified by:
onServiceFailed
in interfaceLogger
- Parameters:
cause
- the reason why the name has failed.
-
onMetricsSnapshot
public void onMetricsSnapshot(io.vertx.core.json.JsonObject metrics)Description copied from interface:Logger
Send METRICS_ENABLED to the logger.- Specified by:
onMetricsSnapshot
in interfaceLogger
- Parameters:
metrics
- a json object containing metrics data to be published
-
onHandlerMissing
Description copied from interface:Logger
Throw when a requested handler was not found.- Specified by:
onHandlerMissing
in interfaceLogger
- Parameters:
target
- the target handlerroute
- the route of the handler
-
onFileLoaded
Description copied from interface:Logger
Emit when a file has been loaded from the file-system.- Specified by:
onFileLoaded
in interfaceLogger
- Parameters:
path
- a path to the loaded file.
-
onError
Description copied from interface:Logger
Log general errors. -
publish
-
onFileLoadError
Description copied from interface:Logger
Emit when failing to load specified fileName;- Specified by:
onFileLoadError
in interfaceLogger
- Parameters:
fileName
- handler of the file that failed to load
-
onFileSaved
Description copied from interface:Logger
Emit when a file has been saved to file.- Specified by:
onFileSaved
in interfaceLogger
- Parameters:
saver
- the component that saved the file.path
- to the saved file.
-
onFileSaveError
Description copied from interface:Logger
Emit when error to save file.- Specified by:
onFileSaveError
in interfaceLogger
- Parameters:
fileName
- handler of the entity that failed saving.
-
onConfigurationDefaultsLoaded
Description copied from interface:Logger
Emit when a configuration was not found on disk and its defaults was loaded from memory.- Specified by:
onConfigurationDefaultsLoaded
in interfaceLogger
- Parameters:
path
- the path to the configurable that was not found.clazz
- the class of the configurable.
-
onInvalidConfigurable
Description copied from interface:Logger
Throw when a configuration was not found and the attempt to instantiate default configuration from the given class has error.- Specified by:
onInvalidConfigurable
in interfaceLogger
- Parameters:
clazz
- a class that is not of Configurable type.
-
onCacheCleared
Description copied from interface:Logger
Emit when the cache of a component has been cleared.- Specified by:
onCacheCleared
in interfaceLogger
- Parameters:
component
- the handler of the component.
-
onSecurityDependencyMissing
Description copied from interface:Logger
Emit when a property in the security configuration is misconfigured.- Specified by:
onSecurityDependencyMissing
in interfaceLogger
- Parameters:
target
- the handler of the target that is missing the requested property identifier.identifier
- the secret that was requested
-
log
-
log
-
onTimerSourceChanged
Description copied from interface:Logger
Emit when the interval of a periodic timer has changed.- Specified by:
onTimerSourceChanged
in interfaceLogger
- Parameters:
name
- handler of the timer that changed intervalinitialTimeout
- the previous value of the intervalnewTimeout
- the new interval of the timer
-
flush
public void flush() -
close
public void close()Description copied from interface:Logger
Shuts down the logger instance, frees any resources such as files or thread pools.
-