0.0
No commit activity in last 3 years
No release in over 3 years
Log4r::Outputter that writes to a Sequel database
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.0, ~> 2.0
= 1.6.4
>= 2.0.0, ~> 2.0

Runtime

>= 3.15.1, ~> 3.15
> 1.1, ~> 1.1.9
>= 4.6.0, ~> 4.6
 Project Readme

log4r-sequel

build status Gem Version Code Climate

Log4r outputter to a Sequel database handle

  • usage
    • pre-built gem installation (stable)
    • from-source installation (latest)
    • demo
  • supported databases
  • notes

the de-facto standard library for logging in Ruby, log4r, works very well for a wide array of logging targets:

  • STDOUT / STDERR
  • file
  • email
  • syslog

and so on, but didn't have a way to output directly to a database - enter log4r-sequel

this project was inspired/motivated by the fact that chainsaw isn't supported on recent versions of OSX.

usage

pre-built gem installation (stable)

gem install log4r-sequel
irb
...
irb(main):001:0> require 'log4r/outputter/sequeloutputter'
=> true
irb(main):002:0> logger = Log4r::Logger.new('foo')
=> #<Log4r::Logger:0x007f889b056df8 @fullname="foo" ...>

from-source installation (latest)

git clone https://github.com/chorankates/log4r-sequel.git
cd log4r-sequel
rake clean build
gem install --local pkg/log4r-sequel*.gem
irb
...
irb(main):001:0> require 'log4r/outputter/sequeloutputter'
=> true

demo

$ ruby example/log2sqlite.rb
2016/08/27 17:08.1472342938 | bar | DEBUG | this is a debug message
2016/08/27 17:08.1472342938 | bar | INFO | this is an info message
2016/08/27 17:08.1472342938 | bar | WARN | this is a warning
2016/08/27 17:08.1472342938 | bar | ERROR | this is an error
2016/08/27 17:08.1472342938 | bar | FATAL | this is a fatal
$ sqlite3 example/log.sqlite
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> select * from logs;
1|2016/08/27 17:10.1472343022|foo|DEBUG|this is a debug message
2|2016/08/27 17:10.1472343022|foo|INFO|this is an info message
3|2016/08/27 17:10.1472343022|foo|WARN|this is a warning
4|2016/08/27 17:10.1472343022|foo|ERROR|this is an error
5|2016/08/27 17:10.1472343022|foo|FATAL|this is a fatal
sqlite>

supported databases

  • sqlite3
  • Postgres

notes

  • :database, :table, and :file options are passed through Time.now.strftime(%s)
  • sqlite filenames cannot contain underscores (the scheme sqlite does not accept registry part)