module Sensu::Logger

Constants

LEVELS

Public Class Methods

get(options={}) click to toggle source

Retrieve the current log stream or set one up if there isn't one. Note: We may need to add a mutex for thread safety.

@param [Hash] options to pass to setup(). @return [Stream] instance of a log stream.

# File lib/sensu/logger.rb, line 28
def get(options={})
  @stream || setup(options)
end
setup(options={}) click to toggle source

Setup a log stream.

@param [Hash] options to create the log stream with. @option options [String] :log_level to use. @option options [String] :log_file to use. @return [Stream] instance of a log stream.

# File lib/sensu/logger.rb, line 12
def setup(options={})
  @stream = Stream.new
  if options[:log_level]
    @stream.level = options[:log_level]
  end
  if options[:log_file]
    @stream.reopen(options[:log_file])
  end
  @stream
end