Class: Hanami::Config::Logger
- Inherits:
-
Object
- Object
- Hanami::Config::Logger
- Defined in:
- lib/hanami/config/logger.rb
Overview
Logger configuration
Instance Attribute Summary collapse
- #application_module ⇒ Object readonly
Instance Method Summary collapse
-
#app_name(value = nil) ⇒ Object
private
Application name value.
-
#build ⇒ Hanami::Logger, Object
private
Returns new Hanami::Logger instance with all options.
-
#engine(value = nil) ⇒ Object
Custom logger engine.
-
#format(value = nil) ⇒ Object
private
Logger format value.
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#level(value = nil) ⇒ Object
Logger level.
-
#stream(value = nil) ⇒ Object
Log stream.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
11 12 13 |
# File 'lib/hanami/config/logger.rb', line 11 def initialize @stream = STDOUT end |
Instance Attribute Details
#application_module ⇒ Object (readonly)
9 10 11 |
# File 'lib/hanami/config/logger.rb', line 9 def application_module @application_module end |
Instance Method Details
#app_name(value) ⇒ Object #app_name ⇒ 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.
Application name value.
135 136 137 138 139 140 141 |
# File 'lib/hanami/config/logger.rb', line 135 def app_name(value = nil) if value.nil? @app_name else @app_name = value end end |
#build ⇒ Hanami::Logger, 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.
Returns new Hanami::Logger instance with all options
194 195 196 197 |
# File 'lib/hanami/config/logger.rb', line 194 def build @engine || ::Hanami::Logger.new(@app_name, stream: @stream, level: @level, formatter: format) end |
#engine(value) ⇒ Object #engine ⇒ Object
Custom logger engine.
This isn’t used by default, but allows developers to use their own logger.
54 55 56 57 58 59 60 |
# File 'lib/hanami/config/logger.rb', line 54 def engine(value = nil) if value.nil? @engine else @engine = value end end |
#format(value) ⇒ Object #format ⇒ 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.
Logger format value.
177 178 179 180 181 182 183 |
# File 'lib/hanami/config/logger.rb', line 177 def format(value = nil) if value.nil? @format else @format = value end end |
#level(value) ⇒ Object #level ⇒ Integer, ...
Logger level
Available values are:
* DEBUG
* INFO
* WARN
* ERROR
* FATAL
* UNKNOWN
115 116 117 118 119 120 121 |
# File 'lib/hanami/config/logger.rb', line 115 def level(value = nil) if value.nil? @level else @level = value end end |
#stream(value) ⇒ Object #stream ⇒ String, ...
Log stream.
STDOUT
by default.
It accepts relative or absolute paths expressed as String
, or Pathname
.
It can also accept a IO
or StringIO
as output stream.
33 34 35 36 37 38 39 |
# File 'lib/hanami/config/logger.rb', line 33 def stream(value = nil) if value.nil? @stream else @stream = value end end |