Giter VIP home page Giter VIP logo

alogr's Introduction

= 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:

  AlogR.new( "log/app_log.log" )
  
  :log specifies the default log
  
  AlogR.new( :log => "log/app_log.log" )

  You may also specify any combination of logs corresponding to the log levels in addition to the default log:

  AlogR.new( :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 = AlogR.new(:log)

  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 "alogr"
$logger = AlogR::Logger.new(:log => "/Users/wayne/projects/ruby/alogr/trunk/log/default.log")
"a test, should go to the logs 10 times\n".log.log.log.log.log.log.log.log.log.log

* Example 2
require "alogr"
$logger = AlogR.new(
: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 = AlogR.new(
: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".log

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

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

"error".log :error

"warning".log :warning

"info".log :info

"yetanother error".log :error

* Example 4
require "lib/alogr"
$logger = AlogR.new(
: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
AlogR.new(:log => "log/production.log", /paypal/ => "log/paypal.log")

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

alogr's People

Contributors

wayneeseguin avatar

Watchers

 avatar

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.