Project

slogger

0.02
No commit activity in last 3 years
No release in over 3 years
Slogger is a Ruby library to help work with standard Ruby Syslog library. Yeah! Just it.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9
~> 2.6.0.rc2
 Project Readme

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) <leandrodoze@gmail.com>.

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.