Giter VIP home page Giter VIP logo

logging_library's Introduction

Build Status Gem Version

LoggingLibrary

This library provides logging support for your application or framework, with an opinionated default configuration in terms of log format, etc.

It is compatible with both JRuby and MRI.

Wraps the functionality of mixlog-log.

Installation

Add this line to your application's Gemfile:

gem 'logging_library'

And then execute:

$ bundle install

Usage

require 'logging_library'

class MyClass
  include LoggingLibrary::Loggable

  def load_data_from_database
    logger.info('Starting to load data from database')

    # DEBUG-level messages are not printed by default; see logger#level= if you
    # want to customize the log level.
    logger.debug("Running as user #{current_user}")

    # If you use blocks to wrap log messages, they'll only execute if needed
    logger.debug { "Score for all participants: #{expensive_operation}" }
  end

  def current_user
    'john_doe'
  end

  def expensive_operation
    sleep 5
    9_000
  end
end

Environment variables

  • LOGGING_LIBRARY_DISABLE_TIMESTAMPS - set this to any value to disable timestamping which is otherwise performed on log entries when running in interactive/TTY mode. This setting can be useful in scenarios where you would otherwise get double timestamps on each line.

  • LOGGING_LIBRARY_ENABLE_TIMESTAMPS - similar to above, but does the exact opposite. This is useful for scenarios where the automatic heuristics is not suitable (for example, log output is being redirected to .log file).

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.

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, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ecraft/logging_library. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Documentation

We strive to write API documentation inline in YARD format.

Generate API documentation using yardoc or rake yard.

Preview API documentation locally with

bundle exec yard server -r

Releasing a new version

  • Bump the version in version.rb

  • Create the tag:

    $ git release v1.0.x`
    
  • Build the gemfile and push it to Rubygems.org:

    $ bundle exec rake build release
  • Generate the changelog (cargo install changelog-rs && changelog-rs .) and copy the relevant lines to the releases page.

License

MIT

logging_library's People

Contributors

perlun avatar olleolleolle avatar

Watchers

James Cloos 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.