Class AbstractLogger

java.lang.Object
java.util.logging.Handler
com.codingchili.core.logging.AbstractLogger
All Implemented Interfaces:
JsonLogger, Logger
Direct Known Subclasses:
ConsoleLogger, RemoteLogger

public abstract class AbstractLogger extends Handler implements Logger
Default logging implementation.
  • Field Details

  • Constructor Details

    • AbstractLogger

      public AbstractLogger(CoreContext context, Class aClass)
    • AbstractLogger

      public AbstractLogger(Class aClass)
  • Method Details

    • log

      public Logger log(io.vertx.core.json.JsonObject json)
      Specified by:
      log in interface JsonLogger
      Parameters:
      json - the data to be logged.
      Returns:
      fluent
    • setMetadata

      public Logger setMetadata(String name, Supplier<io.vertx.core.json.JsonObject> value)
      Description copied from interface: Logger
      Sets a metadata value on the logger.
      Specified by:
      setMetadata in interface Logger
      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

      public Logger setMetadataValue(String key, Supplier<String> value)
      Description copied from interface: Logger
      Sets a metadata value on the logger.
      Specified by:
      setMetadataValue in interface Logger
      Parameters:
      key - the key to put the metadata value in.
      value - a supplier invoked when an event is created.
      Returns:
      fluent.
    • removeMetadata

      public Logger removeMetadata(String nameOrKey)
      Specified by:
      removeMetadata in interface Logger
      Parameters:
      nameOrKey - removes metadata with a matching name or key.
      Returns:
      fluent.
    • event

      public LogMessage event(String name)
      Description copied from interface: Logger
      Creates a logging event using the loggers level.
      Specified by:
      event in interface Logger
      Parameters:
      name - the name of the event.
      Returns:
      a LogMessage with a generated event, level, timestamp and context.
    • event

      public LogMessage event(String name, LogLevel level)
      Description copied from interface: Logger
      Creates a logging event using a provided logger level.
      Specified by:
      event in interface Logger
      Parameters:
      name - the name of the event.
      level - the level.
      Returns:
      a LogMessage with a generated event, level, timestamp and context.
    • onAlreadyInitialized

      public void onAlreadyInitialized()
      Description copied from interface: Logger
      Emit when multiple attempts to initialize singleton.
      Specified by:
      onAlreadyInitialized in interface Logger
    • onServiceStarted

      public void onServiceStarted(CoreService service)
      Description copied from interface: Logger
      Emit when a new server has started.
      Specified by:
      onServiceStarted in interface Logger
      Parameters:
      service - the service that was started
    • onServiceStopped

      public void onServiceStopped(CoreService service)
      Description copied from interface: Logger
      Emit when a server has stopped.
      Specified by:
      onServiceStopped in interface Logger
      Parameters:
      service - the service that was stopped
    • onListenerStarted

      public void onListenerStarted(CoreListener listener)
      Description copied from interface: Logger
      called when a listener is started.
      Specified by:
      onListenerStarted in interface Logger
      Parameters:
      listener - the listener that was started
    • onListenerStopped

      public void onListenerStopped(CoreListener listener)
      Description copied from interface: Logger
      called when a listener is stopped.
      Specified by:
      onListenerStopped in interface Logger
      Parameters:
      listener - the listener that was stopped
    • onServiceFailed

      public void onServiceFailed(Throwable cause)
      Specified by:
      onServiceFailed in interface Logger
      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 interface Logger
      Parameters:
      metrics - a json object containing metrics data to be published
    • onHandlerMissing

      public void onHandlerMissing(String target, String route)
      Description copied from interface: Logger
      Throw when a requested handler was not found.
      Specified by:
      onHandlerMissing in interface Logger
      Parameters:
      target - the target handler
      route - the route of the handler
    • onFileLoaded

      public void onFileLoaded(String path)
      Description copied from interface: Logger
      Emit when a file has been loaded from the file-system.
      Specified by:
      onFileLoaded in interface Logger
      Parameters:
      path - a path to the loaded file.
    • onError

      public void onError(Throwable throwable)
      Description copied from interface: Logger
      Log general errors.
      Specified by:
      onError in interface Logger
      Parameters:
      throwable - the cause for throw.
    • publish

      public void publish(LogRecord record)
      Specified by:
      publish in class Handler
    • onFileLoadError

      public void onFileLoadError(String fileName)
      Description copied from interface: Logger
      Emit when failing to load specified fileName;
      Specified by:
      onFileLoadError in interface Logger
      Parameters:
      fileName - handler of the file that failed to load
    • onFileSaved

      public void onFileSaved(String saver, String path)
      Description copied from interface: Logger
      Emit when a file has been saved to file.
      Specified by:
      onFileSaved in interface Logger
      Parameters:
      saver - the component that saved the file.
      path - to the saved file.
    • onFileSaveError

      public void onFileSaveError(String fileName)
      Description copied from interface: Logger
      Emit when error to save file.
      Specified by:
      onFileSaveError in interface Logger
      Parameters:
      fileName - handler of the entity that failed saving.
    • onConfigurationDefaultsLoaded

      public void onConfigurationDefaultsLoaded(String path, Class<?> clazz)
      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 interface Logger
      Parameters:
      path - the path to the configurable that was not found.
      clazz - the class of the configurable.
    • onInvalidConfigurable

      public void onInvalidConfigurable(Class<?> clazz)
      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 interface Logger
      Parameters:
      clazz - a class that is not of Configurable type.
    • onCacheCleared

      public void onCacheCleared(String component)
      Description copied from interface: Logger
      Emit when the cache of a component has been cleared.
      Specified by:
      onCacheCleared in interface Logger
      Parameters:
      component - the handler of the component.
    • onSecurityDependencyMissing

      public void onSecurityDependencyMissing(String target, String identifier)
      Description copied from interface: Logger
      Emit when a property in the security configuration is misconfigured.
      Specified by:
      onSecurityDependencyMissing in interface Logger
      Parameters:
      target - the handler of the target that is missing the requested property identifier.
      identifier - the secret that was requested
    • log

      public Logger log(String line)
    • log

      public Logger log(String line, LogLevel level)
    • onTimerSourceChanged

      public void onTimerSourceChanged(String name, int initialTimeout, int newTimeout)
      Description copied from interface: Logger
      Emit when the interval of a periodic timer has changed.
      Specified by:
      onTimerSourceChanged in interface Logger
      Parameters:
      name - handler of the timer that changed interval
      initialTimeout - the previous value of the interval
      newTimeout - the new interval of the timer
    • flush

      public void flush()
      Specified by:
      flush in class Handler
    • close

      public void close()
      Description copied from interface: Logger
      Shuts down the logger instance, frees any resources such as files or thread pools.
      Specified by:
      close in interface Logger
      Specified by:
      close in class Handler