Giter Site home page Giter Site logo

rubinius-rails_logger's Introduction

Rubinius::RailsLogger

Logging is essential to monitoring and debugging an application. However, logging infrastructure is often limited. For example, the libc syslog() facility can only be opened once in a process. This prevents Rubinius from using syslog independently of the appliation running on Rubinius. Additionally, concurrent access to the syslog() needs to be synchronized. Finally, configuring a process for logging is a operations-level concern, not an application concern.

Rubinius includes a logging facility that Rubinius uses internally. An API for the facility is exposed to Ruby code. The logger can be configured to use syslog(), as well as STDOUT, STDERR or a file. Support for newer logging facilities like syslog-ng is planned.

The Rubinius::RailsLogger gem provides an adapter for Rails logging that uses the built-in Rubinius logging facility. Some operations are no-ops (eg changing the log level at runtime is not supported).

Installation

Add this line to your application's Gemfile:

gem 'rubinius-rails_logger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rubinius-rails_logger

Usage

Set Rails to use the logger:

# config/environments/production.rb
config.logger = Rubinius::RailsLogger.new "app-name"

Use the same logging API you would expect with, for example, SyslogLogger:

# assume logger is an instance of Rubinius::RailsLogger.

# RailsLogger#write outputs to the log independent of log level.
logger.write "some text"
logger.write { "some text" }

# Other methods only output if the related log level is set. All these
# methods can take a block instead of a message.
logger.fatal "some text"
logger.error "some text"
logger.warn "some text"
logger.info "some text
logger.debug "some text"

# Log level predicates are also available.
logger.fatal?   # => returns true if fatal messages are logged
logger.error?
logger.warn?
logger.info?
logger.debug?

# The following attributes are no-ops, but provided for compatibility. The
# log level is set at process invocation and cannot be changed. The program
# name is set when the logger is created.
logger.formatter
logger.formatter=
logger.level
logger.level=
logger.progname
logger.progname=

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

License

Mozilla Public License, version 2.0. See the LICENSE file for details.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/rubinius-rails_logger/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 a new Pull Request

rubinius-rails_logger's People

Contributors

brixen avatar chrisp avatar jc00ke avatar

Watchers

 avatar  avatar  avatar  avatar  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.