Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 slogger.gemspec
README.rdoc

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

Copyright © 2011 Leandro Silva (CodeZone).

Something went wrong with that request. Please try again.