Class: Hanami::Logger::Colorizer Private

Inherits:
NullColorizer show all
Defined in:
lib/hanami/logger/colorizer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Hanami::Logger Default Colorizer

This colorizer takes in parts of the log message and returns them with proper shellcode to colorize when displayed to a tty.

Since:

  • 1.2.0

Instance Method Summary collapse

Constructor Details

#initialize(colors: COLORS) ⇒ Colorizer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Colorizer.

Since:

  • 1.2.0



32
33
34
# File 'lib/hanami/logger/colorizer.rb', line 32

def initialize(colors: COLORS)
  @colors = colors
end

Instance Method Details

#call(app, severity, datetime, _progname) ⇒ ::Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Colorize the inputs

Parameters:

  • app (#to_s)

    the app name

  • severity (#to_s)

    log severity

  • datetime (#to_s)

    timestamp

  • _progname (#to_s)

    program name - ignored, accepted for compatibility with Ruby’s Logger

Returns:

  • (::Hash)

    an Hash containing the keys ‘:app`, `:severity`, and `:time`

Since:

  • 1.2.0



45
46
47
48
49
50
51
# File 'lib/hanami/logger/colorizer.rb', line 45

def call(app, severity, datetime, _progname)
  ::Hash[
    app:      app(app),
    severity: severity(severity),
    time:     datetime(datetime),
  ]
end