New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

logging_factory

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logging_factory

  • 0.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

LoggingFactory

A wrapper around the logging gem that makes instantiating logs easier. Also has a number of presets for file and standard output logging.

Installation

Add this line to your application's Gemfile:

gem 'logging_factory'

And then execute:

$ bundle

Or install it yourself as:

$ gem install logging_factory

Usage

By default all output is written to standard output. To use in your project:

 public class MyClass
    def initialize()
       log = LoggingFactory::DEFAULT_FACTORY.log(self.class)
    end
 end

This will instantiate a log with the default configuration, specified by LoggingFactory::DEFAULT_LOG_CONFIGURATION:

  {
     output: 'STDOUT',
     truncate: false,
     level: :debug,
     format: '[%d] %-5l [%c]: %m\n'
 }
 

To override this configuration you can modify a log instance like this:

 public class MyClass
    def initialize()
       log = LoggingFactory::DEFAULT_FACTORY.log(self.class, output: 'myproject.log')
    end
 end

Or create a new factory instant for use in your project:

 MY_LOG_FACTORY = LoggingFactory.create (
     output: 'myproject.log'
 )

This will create an factory that will use the myproject.log for logging. Other options which are no supplied will fall back to the default unless explicitly overridden.

Examples

See spec/my_log.log for an example (run tests to generate this file).

Standard output:

Log file:

[2013-09-19 23:12:18] DEBUG [LogExample] This is a debug message
[2013-09-19 23:12:18] INFO  [LogExample] This is an informational message
[2013-09-19 23:12:18] WARN  [LogExample] This is an warning message
[2013-09-19 23:12:18] ERROR [LogExample] This is an error message
[2013-09-19 23:12:18] FATAL [LogExample] This is a fatal message

Contributing

  1. Fork it
  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

FAQs

Package last updated on 20 Jun 2014

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