Sha256: 243ae2210d311120d953c62ba051acf0ca655e351ec059b65bb0c0cc969d6fae

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

# Sinatra::Log ![Build Status][1]

A simple file logger written for use by Sinatra apps.

## Installation

Add this line to your application's Gemfile:

    gem 'sinatra-log'

And then execute:

    $ bundle install

Or install it globally:

    $ gem install sinatra-log

## Usage

```
class MyProject
  def self.log
    @logger ||= Sinatra::Log.new(:logger_name => 'myproject',
                                 :log_filename => '/var/log/development.log',
  				 :loglevel => 'WARN',
  				 :enabled => true,
  				 :project_dir => '/var/opt/myproj')
  end
end

MyProject.log.error "Error level log" 	# You will see this
MyProject.log.warn "Warning level log"  # You will see this
MyProject.log.info "Info level log"     # But not this
MyProject.log.debug "Debug level log"   # or this

```

This will configure the logger to output messages at WARN level or higher to
be directed to the location /var/log/development.log. Logging is enabled and
the log4r logger is named 'myproject'.

Each log messages that is generated by log4r will contain the full path and
filename of the origin of the log message. Specifying the project root
directory in :project_dir, will cause that directory to be removed from each
log message.

## History

I wrote this wrapper around log4r in 2014 for a small Sinatra project at
[Lookout][4]. As the project ended, the code was pulled out
and open sourced by [ismith][3] and included in [lookout-rack-utils][2].

## Changes

The changes here remove the Lookout specific bits of the logging - the use of
specific configatron values that may not match your project or style.
Graphite logging was also thrown out, though that could be re-added if
desired. And of course there was a namespace change.

[1]: https://api.travis-ci.org/svrana/sinatra-log.svg?branch=master
[2]: https://github.com/lookout/lookout-rack-utils.git
[3]: https://github.com/ismith
[4]: https://lookout.com

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-log-0.1.2 README.md