Module: BeanStalk::Worker::Log

Extended by:
Mixlib::Log
Defined in:
lib/beanstalk-worker/logger.rb

Overview

Beanstalk::Worker’s internal logging facility. Standardized to provide a consistent log format.

Defined Under Namespace

Classes: Formatter

Class Method Summary collapse

Class Method Details

.init(*opts) ⇒ Object

Use Mixlib::Log.init when you want to set up the logger manually. Arguments to this method get passed directly to Logger.new, so check out the documentation for the standard Logger class to understand what to do here.

If this method is called with no arguments, it will log to STDOUT at the :warn level.

It also configures the Logger instance it creates to use the custom Mixlib::Log::Formatter class.



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

def init(*opts)
  reset!
  @logger = logger_for(BeanStalk::Worker::Config[:log_location])
  if @logger.respond_to?(:formatter=)
    if BeanStalk::Worker::Config[:log_formatter].eql?(:json)
      @logger.formatter = Mixlib::Log::JSONFormatter.new()
    else
      @logger.formatter = Mixlib::Log::Formatter.new()
    end
  end
  @logger.level = Logger.const_get(
    BeanStalk::Worker::Config[:log_level].to_s.upcase)
  @logger
end