Class: Hanami::Logger::Formatter Private

Inherits:
Logger::Formatter
  • Object
show all
Includes:
Utils::ClassAttribute
Defined in:
lib/hanami/logger.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

Defined Under Namespace

Classes: HashFilter

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

' '.freeze
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



162
163
164
# File 'lib/hanami/logger.rb', line 162

def application_name
  @application_name
end

#hash_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.1.0



166
167
168
# File 'lib/hanami/logger.rb', line 166

def hash_filter=(value)
  @hash_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



138
139
140
# File 'lib/hanami/logger.rb', line 138

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

.fabricate(formatter, application_name, filters) ⇒ 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



122
123
124
125
126
127
128
129
# File 'lib/hanami/logger.rb', line 122

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

  fabricated_formatter.application_name = application_name
  fabricated_formatter.hash_filter      = HashFilter.new(filters)

  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



132
133
134
135
# File 'lib/hanami/logger.rb', line 132

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.



172
173
174
175
176
177
178
179
180
# File 'lib/hanami/logger.rb', line 172

def call(severity, time, _progname, msg)
  _format({
    app:      application_name,
    severity: severity,
    time:     time
  }.merge(
    _message_hash(msg)
  ))
end