Class: DslEvaluator::Logger
- Inherits:
-
Logger
- Object
- Logger
- DslEvaluator::Logger
- Defined in:
- lib/dsl_evaluator/logger.rb
Instance Method Summary collapse
- #format_message(severity, datetime, progname, msg) ⇒ Object
-
#initialize(*args) ⇒ Logger
constructor
A new instance of Logger.
-
#stdout(msg, newline: true) ⇒ Object
Used to allow output to always go to stdout.
Constructor Details
#initialize(*args) ⇒ Logger
Returns a new instance of Logger.
3 4 5 6 7 |
# File 'lib/dsl_evaluator/logger.rb', line 3 def initialize(*args) super self.formatter = Formatter.new self.level = ENV["DSL_EVALUATOR_LOG_LEVEL"] || :info # note: only respected when config.logger not set in config/app.rb end |
Instance Method Details
#format_message(severity, datetime, progname, msg) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/dsl_evaluator/logger.rb', line 9 def (severity, datetime, progname, msg) line = if @logdev.dev == $stdout || @logdev.dev == $stderr || @logdev.dev.is_a?(StringIO) msg # super simple format if stdout else super # use the configured formatter end /\n$/.match?(line) ? line : "#{line}\n" end |
#stdout(msg, newline: true) ⇒ Object
Used to allow output to always go to stdout
19 20 21 22 23 24 25 |
# File 'lib/dsl_evaluator/logger.rb', line 19 def stdout(msg, newline: true) if newline puts msg else print msg end end |