Class: Low::Rack::LogLevel
- Inherits:
-
Object
- Object
- Low::Rack::LogLevel
- Defined in:
- lib/low/rack/log_level.rb
Constant Summary collapse
- DEFAULT_DEFAULT_LEVEL =
Logger::INFO
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ LogLevel
constructor
A new instance of LogLevel.
- #log_level ⇒ Object
Constructor Details
#initialize(app, opts = {}) ⇒ LogLevel
Returns a new instance of LogLevel.
9 10 11 12 |
# File 'lib/low/rack/log_level.rb', line 9 def initialize(app, opts = {}) @app = app @default_level = opts[:default_level] || DEFAULT_DEFAULT_LEVEL end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 |
# File 'lib/low/rack/log_level.rb', line 14 def call(env) env['low.log_level'] ||= log_level @app.call(env) end |
#log_level ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/low/rack/log_level.rb', line 19 def log_level # If `LOG_LEVEL` is a valid level if ['FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'].include? ENV['LOG_LEVEL'] # use it; eval "Logger::#{ENV['LOG_LEVEL']}" else # otherwise, use the default @default_level end end |