Class: Escort::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/escort/logger.rb

Class Method Summary collapse

Class Method Details

.closeObject


6
7
8
9
# File 'lib/escort/logger.rb', line 6

def close
  error.close
  output.close
end

.errorObject


11
12
13
14
15
16
17
# File 'lib/escort/logger.rb', line 11

def error
  @error_logger ||= ::Logger.new($stderr).tap do |l|
    #l.formatter = advanced_error_formatter
    l.formatter = basic_error_formatter
    l.sev_threshold = ::Logger::WARN
  end
end

.outputObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/escort/logger.rb', line 19

def output
  @output_logger ||= ::Logger.new($stdout).tap do |l|
    l.formatter = output_formatter
    l.sev_threshold = ::Logger::DEBUG
    l.instance_eval do
      def puts(message = nil, &block)
        if block_given?
          fatal(&block)
        else
          fatal(message || "")
        end
      end
    end
  end
end

.setup_error_logger(auto_options) ⇒ Object


35
36
37
38
# File 'lib/escort/logger.rb', line 35

def setup_error_logger(auto_options)
  error.formatter = send(:"#{auto_options.error_formatter}_error_formatter")
  error.sev_threshold = ::Logger.const_get(auto_options.verbosity)
end