Bamm Log

A Sinatra Logger

For the record.. this is a WIP gem..

By default Sinatra logs this:

127.0.0.1 - - [25/Aug/2014 17:23:11] "GET /page HTTP/1.1" 200 6736 2.5322
127.0.0.1 - - [25/Aug/2014 17:24:33] "POST /create HTTP/1.1" 200 5833 0.0198

/create with which params?

127.0.0.1 - - [25/Aug/2014 17:24:33] "POST /error HTTP/1.1" 500 5443 0.1238

This page returns 500 for what? You can check your apache error.log file or you can log everything to one file, like Rails do.

After reading some implementations, I joined some ideas and created this gem. It's not tested yet, so.. don't use it on production.

[2014-08-25 16:03:43 +0000] Started GET "/page?page=1&per_page=99"
[2014-08-25 16:03:43 +0000] Parameters: "per_page"=>"99"

[2014-08-25 17:36:59 +0000] Started POST "/create"
[2014-08-25 17:36:59 +0000] Parameters: "title" => "Nice and Clean" }

[2014-08-25 17:36:59 +0100] Started GET "/v0/page?page=1&per_page=99"
[2014-08-25 17:36:59 +0100] Parameters: "per_page"=>"99"
[2014-08-25 17:37:05 +0100] Bamm! RuntimeError: bamm error
[2014-08-25 17:37:05 +0100] /app/routes/page.rb:4:in `block in class:App'

extended backtrace...

Installation

Add this line to your application's Gemfile:

gem 'bamm_log'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bamm_log

Usage

Include in your app

class App < Sinatra::Base

  include BammLog::Logger

end

And add manual logs

BammLog.print "This is a log"

In development environment, bamm_log logs to your terminal.
In live environment, training or staging, bamm_log creates a file with the name "environment".log in /log and logs all the accesses and errors from your application.

Contributing

  1. Fork it ( http://github.com/joaquimadraz/bamm_log/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request