Class: StructuredEventLogger::HumanReadableLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_event_logger/human_readable_logger.rb

Constant Summary collapse

CLEAR =
"\e[0m"
BOLD =
"\e[1m"
MAGENTA =

Colors

"\e[35m"
CYAN =
"\e[36m"
WHITE =
"\e[37m"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, colorize = ActiveSupport::LogSubscriber.colorize_logging, log_level = nil) ⇒ HumanReadableLogger

Returns a new instance of HumanReadableLogger.



15
16
17
# File 'lib/structured_event_logger/human_readable_logger.rb', line 15

def initialize(logger, colorize = ActiveSupport::LogSubscriber.colorize_logging, log_level = nil)
  @logger, @colorize, @log_level = logger, colorize, log_level
end

Instance Attribute Details

#colorizeObject

Returns the value of attribute colorize.



13
14
15
# File 'lib/structured_event_logger/human_readable_logger.rb', line 13

def colorize
  @colorize
end

#log_levelObject

Returns the value of attribute log_level.



13
14
15
# File 'lib/structured_event_logger/human_readable_logger.rb', line 13

def log_level
  @log_level
end

#loggerObject

Returns the value of attribute logger.



13
14
15
# File 'lib/structured_event_logger/human_readable_logger.rb', line 13

def logger
  @logger
end

Instance Method Details

#call(scope, event, hash, decorated_hash) ⇒ Object



20
21
22
# File 'lib/structured_event_logger/human_readable_logger.rb', line 20

def call(scope, event, hash, decorated_hash)
  logger.add(log_level, format_hash(scope, event, hash))
end