Sha256: 352ce21cb8e6ef82bf973f0702528eab09d2cfc5d283fdc689c50c0f73d4f210

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

module Slogger
  #
  # The wrapper for standard Ruby Syslog library.
  #
  # Sample:
  #
  # slogger = Slogger::Logger.new "sample_app", :info, :local0 
  # slogger.info "A good info"
  # slogger.debug "A deep info (oops! it'll not be logged)"
  #
  class Logger < Base

    #
    # Just sugars
    #
    SEVERITIES = ::Slogger::Base::SYSLOG_SEVERITIES
    FACILITIES = ::Slogger::Base::SYSLOG_FACILITIES
    
    #
    # To build a Slogger::Logger instance.
    #
    # +app_name+::  The appliaction name to be logged
    # +severity+::  The log severity: :emerg, :alert, :crit, :err, :warning, :notice,
    #                 :info, or :debug. It can be changed at anytime.
    # +facility+::  A typical syslog facility: :kernel, :user, :mail, :daemon, :auth,
    #                 :syslog, :lpr, :news, :uucp, :cron, :authpriv, :ftp,
    #                 :local0, :local1, :local2, :local3, :local4, :local5,
    #                 :local6, or :local7
    #
    # Raises an ArgumentError if app_name, severity, or facility is nil.
    #
    def initialize(app_name, severity, facility)
      super app_name, severity, facility
    end
    
    SEVERITIES.each_key do |severity|
      define_method severity do |message, &block|
        log severity, message, &block
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slogger-0.0.12 lib/slogger/logger.rb
slogger-0.0.11 lib/slogger/logger.rb
slogger-0.0.10 lib/slogger/logger.rb
slogger-0.0.9 lib/slogger/logger.rb
slogger-0.0.8 lib/slogger/logger.rb
slogger-0.0.7 lib/slogger/logger.rb
slogger-0.0.6 lib/slogger/logger.rb
slogger-0.0.5 lib/slogger/logger.rb
slogger-0.0.4 lib/slogger/logger.rb