Skip to content

Slogger is a Ruby library to help work with standard Ruby Syslog library

Notifications You must be signed in to change notification settings

leandrosilva/slogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slogger

Slogger is a Ruby library to help work with standard Ruby Syslog library.

Install

Slogger is hosted on RubyGems (rubygems.org/gems/slogger), so to install it is really easy.

$ gem install slogger

Features

Slogger::Logger

A more friendly wrapper on Ruby’s Syslog.

Sample: simple message log

require "slogger"

# So in this sample:
#
# "sample_name": application name
# :info        : severity level
# :local0      : facility

slogger = Slogger::Logger.new "sample_app", :info, :local0 
slogger.info "A good info"
slogger.debug "A deep info (oops!)"  # it'll not be logged

slogger.severity = :debug
slogger.debug "A deep info (yay!)"   # now it'll be logged

# and after, look at the syslog file of your SO  ;)

Sample: message log preceded by spent time

require "slogger"

slogger = Slogger::Logger.new "sample_app", :debug, :local0 
slogger.info "A really good info preceded by spent time" do
  # do something
end

# and after, look at the syslog file of your SO  ;)

Slogger::CommonLogger

A useful class which exposes the Ruby’s standard Syslog with the same API that Ruby’s standard Logger to be used, for example, in Rails applications.

Just add the snippet below to the config/environments/developement.rb of an Rails application and everything will be logged thru the Ruby’s standard Syslog library:

config.log_level = :info
config.logger = Slogger::CommonLogger.new "rappils", config.log_level, :local0

Slogger::Rack::RequestLogger

A Rack middleware to log incoming requests.

Sample:

require "slogger"

configure do
  slogger = Slogger::Logger.new "sample_app", :debug, :local0
  use Slogger::Rack::RequestLogger, slogger
end

# and after, look at the syslog file of your SO  ;)

Future

I don’t know. I think in adding more stuff sometime in the future. Let’s see.

For now is it.

Quick view on Syslog RFC 5424

If you want to get a look at RFC 5424, which I really recommend, you can go to:

tools.ietf.org/html/rfc5424

According to that:

# Message Severities
#
# - Emergency: system is unusable
# - Alert: action must be taken immediately
# - Critical: critical conditions
# - Error: error conditions
# - Warning: warning conditions
# - Notice: normal but significant condition
# - Informational: informational messages
# - Debug: debug-level messages

And…

# Message Facilities
#
# - kernel messages
# - user-level messages
# - mail system
# - system daemons
# - security/authorization messages
# - messages generated internally by syslogd
# - line printer subsystem
# - network news subsystem
# - UUCP subsystem
# - clock daemon
# - security/authorization messages
# - FTP daemon
# - NTP subsystem
# - log audit
# - log alert
# - clock daemon (note 2)
# - local use 0  (local0)
# - local use 1  (local1)
# - local use 2  (local2)
# - local use 3  (local3)
# - local use 4  (local4)
# - local use 5  (local5)
# - local use 6  (local6)
# - local use 7  (local7)

Copyright © 2011 Leandro Silva (CodeZone) <[email protected]>.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

About

Slogger is a Ruby library to help work with standard Ruby Syslog library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages