Sha256: ec83dd85da15568344ba745d891305deb6916ffe5cc53e760cc85bbbe927b461

Contents?: true

Size: 718 Bytes

Versions: 18

Compression:

Stored size: 718 Bytes

Contents

require 'syslog'

module Klogger
  class Syslog < KloggerBase

    def start_plugin
      start_syslog(@config[:ident] || 'klogger',
                   @config[:options] || ::Syslog::LOG_PID | ::Syslog::LOG_NDELAY,
                   @config[:facility] || ::Syslog::LOG_LOCAL0)
    end

    def on_event(event)
      say_event(event)
    end

    def stop_plugin
      stop_syslog
    end

    private

    def say_event(event)
      say(KloggerBase.event_to_hash(event).to_s)
    end

    def say(msg)
      ::Syslog.log(::Syslog::LOG_INFO, msg)
    end

    def start_syslog(ident, options, facility)
      ::Syslog.open(ident, options, facility)
    end

    def stop_syslog
      ::Syslog.close
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
klogger-4.0.0 lib/klogger/syslog.rb
klogger-3.0.0 lib/klogger/syslog.rb
klogger-2.0.0 lib/klogger/syslog.rb
klogger-1.7.0 lib/klogger/syslog.rb
klogger-1.6.5 lib/klogger/syslog.rb
klogger-1.6.4 lib/klogger/syslog.rb
klogger-1.6.3 lib/klogger/syslog.rb
klogger-1.6.2 lib/klogger/syslog.rb
klogger-1.6.1 lib/klogger/syslog.rb
klogger-1.6.0 lib/klogger/syslog.rb
klogger-1.5.0 lib/klogger/syslog.rb
klogger-1.4.0 lib/klogger/syslog.rb
klogger-1.3.0 lib/klogger/syslog.rb
klogger-1.2.0 lib/klogger/syslog.rb
klogger-1.1.0 lib/klogger/syslog.rb
klogger-1.0.2 lib/klogger/syslog.rb
klogger-1.0.1 lib/klogger/syslog.rb
klogger-1.0.0 lib/klogger/syslog.rb