Class: Lamian::SemanticLoggerAppender

Inherits:
SemanticLogger::Subscriber
  • Object
show all
Defined in:
lib/lamian/semantic_logger_appender.rb

Overview

Custom appender for the ‘semantic_logger` library. This appender adds all logs to the current Lamian logger. Since Lamian stores logs in a thread variable, it is necessary that this appender writes logs synchronously: just call `SematicLogger.sync!` somewhere in the initialization process.

Constant Summary collapse

LOGGER_LEVELS_MAPPING =

Mapping between standard Logger severity and SemanticLogger log levels.

{ trace: 0, debug: 0, info: 1, warn: 2, error: 3, fatal: 4 }.freeze

Instance Method Summary collapse

Instance Method Details

#log(log) ⇒ Object

The method to be implemented when creating a custom appender.



17
18
19
20
21
22
# File 'lib/lamian/semantic_logger_appender.rb', line 17

def log(log)
  mapped_level = LOGGER_LEVELS_MAPPING[log.level] || ::Logger::UNKNOWN
  Lamian::Logger.current.add(mapped_level, log.message)

  true
end