larskrantz / rails

ActiveSupport::Logger plugin for LogDNA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails logger plugin for logging to LogDNA


Overview

This gem contains LogDNA::RailsLogger, a plugin for ActiveSupport::Logger from Rails.

Installation

Add this line to your application's Gemfile:

gem 'logdna-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install logdna-rails

API

::new(api_key, hostname, options = {})

Instantiates a new instance of the class it is called on. api_key and hostname are required.

Options:

  • logdev: The log device. This is a filename (String) or IO object (e.g. STDOUT, STDERR, an open file). Default: STDOUT.
  • shift_age: Number of old log files to keep, or frequency of rotation (daily, weekly, or monthly). Default: 7.
  • shift_size: Maximum logfile size (only applies when shift_age is a number). Default: 1,048,576
  • buffer_max_size: Maximum number of lines in buffer.
  • buffer_timeout: Frequency of posting requests to LogDNA.
  • mac: MAC address. Default: nil.
  • ip: IP address. Default: nil.

#add

Log a message if the given severity is high enough and post it to the LogDNA ingester. This is the generic logging method. Users will be more inclined to use debug, info, warn, error, and fatal (which all call #add), as described in the Ruby Logger documentation. Note that these methods take a source as the argument and a block which returns a message. It returns the http response.

#close_http

Close the HTTP connection to LogDNA's ingester.

#reopen_http

Open another HTTP connection to LogDNA's ingester if the connection is alread closed.

Development

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/logdna/rails.

License

The gem is available as open source under the terms of the MIT License.

About

ActiveSupport::Logger plugin for LogDNA

License:MIT License


Languages

Language:Ruby 96.7%Language:Shell 3.3%