Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

AlogR is a threadsafe non-blocking asynchronous configurable logger for Ruby.

tree: dfb4133fab

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext
Octocat-spinner-32 lib
Octocat-spinner-32 specs
Octocat-spinner-32 README
Octocat-spinner-32 TODO
= About

  AlogR enables a Ruby project to log to the filesystem using non-blocking asynchronous IO with no external dependencies.

= Author

  Wayne E. Seguin (wayneeseguin at gmail dot com)

= How it works

  A global logging buffer gets added to the running application.
  There is a global buffer which is an array of fifo queues.
  Worker threads are to pop the first element (which is a string) off of a fifo queue and "process" it. 
  Processing involves writing the string to disk using non-blocking asynchronous IO
  Threads will be event based where the event is something being placed in the queue, or the queue non-empty.
= Config
  You can choose the log that the application uses: "log/app_log.log" )
  :log specifies the default log :log => "log/app_log.log" )

  You may also specify any combination of logs corresponding to the log levels in addition to the default log: :log => "log/app_log.log", :error => "log/error.log", :debug => "log/debug.log")

  where log levels are one of: [ emergency, alert, critical, error, warning, notice, info, debug ] 

= Application Usage

  First be sure to setup the logger:

  $alogger =

  To log a string to either the error log or the default log (depending on your configuration):

  "Jonnie! You borked it!".log(:error)

Feature Requests:
# Be able to specify conditional filters

= Examples

* Example 1
require "lib/alogr"
$logger = => "/Users/wayne/projects/ruby/alogr/trunk/log/production.log")
"a test, should go to the logs 10 times\n".log.log.log.log.log.log.log.log.log.log

* Example 2
require "lib/alogr"
$logger =
:log => "/Users/wayne/projects/ruby/alogr/trunk/log/production.log", 
:error => "/Users/wayne/projects/ruby/alogr/trunk/log/error.log"

"(1)this should go to the production log\n".log

"(2)this should go to error log\n".log(:error)

"(3)error\n".log :error

"(4)production\n".log :info

"(5)error".log :error

* Example 3
require "lib/alogr"
$logger =
:log => "/Users/wayne/projects/ruby/alogr/trunk/log/production.log", 
:error => "/Users/wayne/projects/ruby/alogr/trunk/log/error.log",
:info => "/Users/wayne/projects/ruby/alogr/trunk/log/info.log",
:warning => "/Users/wayne/projects/ruby/alogr/trunk/log/warning.log"

"this should go to info log\n".log

"this should go to error log\n".log(:error)

"this should go to production log\n".log(:warning)

"error".log :error

"warning\n".log :warning

"info\n".log :info

"yetanother error\n".log :error

* Example 4
require "lib/alogr"
$logger =
:log => "/Users/wayne/projects/ruby/alogr/trunk/log/production.log", 
:error => "/Users/wayne/projects/ruby/alogr/trunk/log/error.log",
:info => "/Users/wayne/projects/ruby/alogr/trunk/log/info.log",
/paypal => "/Users/wayne/projects/ruby/alogr/trunk/log/paypal.log"
"this should go to info log".log
"this should go to error log".log(:error)
"this should go to production log".log(:warning)

* Example 4:
If line matches a regexp then sent log/paypal.log as well as production.log => "log/production.log", /paypal/ => "log/paypal.log")

Gets logged to both
{ :something => "value", :something_else => "value" }.log

Something went wrong with that request. Please try again.