Coder Social home page Coder Social logo

slogger's Introduction

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.

slogger's People

Contributors

leandrosilva avatar rhruiz avatar rodrigues avatar caius avatar davidlins avatar kina avatar

Stargazers

Angus H. avatar Ilya Lavrov avatar Christoph Grabo avatar Andreas Tiefenthaler avatar Nick Willever avatar Diogo Souza da Silva avatar Tommy avatar Felix Gallo avatar Leandro Proença avatar Olivia avatar  avatar Mateus Prado avatar  avatar Gus Becciu avatar  avatar  avatar Tomas D'Stefano avatar Max Justus Spransy avatar Alisson Sales avatar Tsyren O. avatar Gregory Loscombe avatar PotHix avatar Everton Ribeiro avatar Justin Mazzi avatar

Watchers

 avatar James Cloos avatar

slogger's Issues

Code License

I have a project where I’d like to use the slogger gem, however you don’t currently have a license. Would you consider releasing it under an open source license such as MIT?

Syntax error in 1.8.7

Seems to load fine in 1.9 for me, but for 1.8.7 I end up with this:

slogger-0.0.7/lib/slogger/common_logger.rb:72: syntax error, unexpected '=', expecting '|' (SyntaxError)
  define_method severity do |message = nil, &block|
                                      ^
slogger-0.0.7/lib/slogger/common_logger.rb:72: Can't assign to nil
  define_method severity do |message = nil, &block|
                                           ^
slogger-0.0.7/lib/slogger/common_logger.rb:73: syntax error, unexpected tCONSTANT, expecting kDO or '{' or '('
    log BRIDGE_SEVERITIES[severity], message, &block
                         ^
slogger-0.0.7/lib/slogger/common_logger.rb:73: syntax error, unexpected tAMPER, expecting '='
    log BRIDGE_SEVERITIES[severity], message, &block
                                               ^
slogger-0.0.7/lib/slogger/common_logger.rb:81: syntax error, unexpected kEND, expecting $end
from /Users/mseeger/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from slogger-0.0.7/lib/slogger.rb:6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.