Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easy_logging

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy_logging

  • 0.4.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

EasyLogging

Ruby utility that lets you include logging anywhere easily, without redundancy.
BranchStatus
ReleaseBuild Status Coverage Status Gem Version Total Downloads
DevelopmentBuild Status Coverage Status

Features

  • Adds logging functionality anywhere with one, short, descriptive command
  • Logger works in both class and instance methods
  • Logger is specific to class and contains class name
  • Logger is configurable (destination, level, formatter)

Installation

Add this line to your application's Gemfile:

gem 'easy_logging'

And then execute:

$ bundle

Or install it yourself as:

$ gem install easy_logging

Usage

Add include EasyLogging to any context (e.g. a class) you want to extend with logging functionality.

require 'easy_logging'
EasyLogging.log_destination = 'app.log'
EasyLogging.level = Logger::DEBUG

class YourClass
  include EasyLogging

  def do_something
    # ...
    logger.info 'something happened'
  end
end

class YourOtherClass
  include EasyLogging

  def self.do_something
    # ...
    logger.info 'something happened'
  end
end

YourClass.new.do_something
YourOtherClass.do_something

Output:

I, [2017-06-03T21:59:25.160686 #5900]  INFO -- YourClass: something happened
I, [2017-06-03T21:59:25.160686 #5900]  INFO -- YourOtherClass: something happened

Configuration

Log settings are global for all loggers. Always configure EasyLogging before loading your application.

Destination
EasyLogging.log_destination = 'app.log'

Default: STDOUT

Since: v0.2.0

Level
EasyLogging.level = Logger::DEBUG

Default: Logger::INFO

Since: v0.3.0

Formatter
EasyLogging.formatter = proc do |severity, datetime, progname, msg|
 severity + datetime + progname + msg
end

Default: Logger default

Since: v0.3.0

Changing configuration on the fly

... is tricky but looking at the specs it's fairly easy to understand:

describe 'on the fly modification of logger configuration' do
  context 'class level logger' do
    it 'uses old config if EasyLogging was included before config change'
    it 'uses new config if EasyLogging was included after config change'
  end

  context 'instance level logger' do
    it 'uses old config if instance was created before config change'
    it 'uses new config if instance was created after config change'
  end
end

Feedback

Any feedback is much appreciated.

I can only tailor this project to fit use-cases I know about - which are usually my own ones. If you find that this might be the right direction to solve your problem too but you find that it's suboptimal or lacks features don't hesitate to contact me.

Please let me know if you make use of this project so that I can prioritize further efforts.

Development

This gem is developed using Bundler conventions. A good overview can be found here.

Contributing

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

License

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

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc