Class: Hanami::Logger::Formatter Private

Inherits:
Logger::Formatter
  • Object
show all
Includes:
Utils::ClassAttribute
Defined in:
lib/hanami/logger/formatter.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 formatter. This formatter returns string in key=value format.

Direct Known Subclasses

JSONFormatter

Constant Summary collapse

SEPARATOR =

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

Since:

  • 0.8.0

" "
NEW_LINE =

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

Since:

  • 0.8.0

$/
RESERVED_KEYS =

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

Since:

  • 1.0.0

%i[app severity time].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::ClassAttribute

included

Instance Attribute Details

#application_nameObject

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.

Since:

  • 1.0.0



81
82
83
# File 'lib/hanami/logger/formatter.rb', line 81

def application_name
  @application_name
end

#colorizer=(value) ⇒ Object (writeonly)

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.

Since:

  • 1.2.0



89
90
91
# File 'lib/hanami/logger/formatter.rb', line 89

def colorizer=(value)
  @colorizer = value
end

#filter=(value) ⇒ Object (writeonly)

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.

Since:

  • 1.2.0



85
86
87
# File 'lib/hanami/logger/formatter.rb', line 85

def filter=(value)
  @filter = value
end

Class Method Details

.eligible?(name) ⇒ Boolean

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:

Since:

  • 0.5.0



57
58
59
# File 'lib/hanami/logger/formatter.rb', line 57

def self.eligible?(name)
  name == :default
end

.fabricate(formatter, application_name, filters, colorizer) ⇒ Object

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.

Since:

  • 0.5.0



40
41
42
43
44
45
46
47
48
# File 'lib/hanami/logger/formatter.rb', line 40

def self.fabricate(formatter, application_name, filters, colorizer)
  fabricated_formatter = _formatter_instance(formatter)

  fabricated_formatter.application_name = application_name
  fabricated_formatter.filter           = Filter.new(filters)
  fabricated_formatter.colorizer        = colorizer

  fabricated_formatter
end

.inherited(subclass) ⇒ Object

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.

Since:

  • 0.5.0



51
52
53
54
# File 'lib/hanami/logger/formatter.rb', line 51

def self.inherited(subclass)
  super
  subclasses << subclass
end

Instance Method Details

#call(severity, time, progname, msg) ⇒ Object

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.



95
96
97
98
99
100
# File 'lib/hanami/logger/formatter.rb', line 95

def call(severity, time, progname, msg)
  colorized = @colorizer.call(application_name, severity, time, progname)
  colorized.merge!(_message_hash(msg))

  _format(colorized)
end