Class: Dry::Logger::Formatters::String

Inherits:
Structured
  • Object
show all
Defined in:
lib/dry/logger/formatters/string.rb

Overview

Basic string formatter.

This formatter returns log entries in key=value format.

Since:

  • 1.0.0

Direct Known Subclasses

Rack

Constant Summary collapse

HASH_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:

  • 1.0.0

","
EXCEPTION_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:

  • 1.0.0

": "
DEFAULT_SEVERITY_COLORS =

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.2.0

{
  DEBUG => :cyan,
  INFO => :magenta,
  WARN => :yellow,
  ERROR => :red,
  FATAL => :red,
  UNKNOWN => :blue
}.freeze

Constants inherited from Structured

Dry::Logger::Formatters::Structured::DEFAULT_FILTERS, Dry::Logger::Formatters::Structured::NOOP_FILTER

Instance Attribute Summary collapse

Attributes inherited from Structured

#filter, #options

Instance Method Summary collapse

Methods inherited from Structured

#call, #format_values

Constructor Details

#initialize(template: Logger.templates[:default], **options) ⇒ String

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 String.

Since:

  • 1.0.0



43
44
45
46
# File 'lib/dry/logger/formatters/string.rb', line 43

def initialize(template: Logger.templates[:default], **options)
  super(**options)
  @template = Template[template]
end

Instance Attribute Details

#templateObject (readonly)

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



39
40
41
# File 'lib/dry/logger/formatters/string.rb', line 39

def template
  @template
end

Instance Method Details

#colorize?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:

  • (Boolean)

Since:

  • 1.0.0



50
51
52
# File 'lib/dry/logger/formatters/string.rb', line 50

def colorize?
  options[:colorize].equal?(true)
end