GithubHelp home page GithubHelp logo

classicvalues / paul_bunyan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from instructure/paul_bunyan

1.0 1.0 0.0 124 KB

License: MIT License

Ruby 92.98% Shell 0.08% JavaScript 0.71% CSS 0.70% HTML 4.97% Dockerfile 0.57%

paul_bunyan's Introduction

Paul Bunyan (formerly: Logging)

Gem Build Status Dependency Status

PaulBunyan is a re-usable component with a globally accessible Logger with extra support for handling logging in Rails.

class Foo
  include PaulBunyan

  def bar
    logger.warn "blah"
  end
end

Also included is a Railtie that overrides the default rails logger to always print to STDOUT as well as format the messages to JSON for machine readable goodness. This has been tested with Rails 4.2 through 5.1, older versions of Rails may work but are not guaranteed to and will not receive support.

Installation

Add this line to your application's Gemfile:

gem 'paul_bunyan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paul_bunyan

Usage

Non-Rails projects:

require 'paul_bunyan'

include PaulBunyan

logger.warn "blah"

Rails projects:

Nothing after it's added to your Gemfile, the Railtie takes care of the rest.

Adding metadata to JSON logs

The default logger includes the ability to accept arbitrary metadata, the primary use case for this functionality is to add context to log lines generated in the course of processing a Rails request. There is an example for adding the request host to the metadata in the examples directory. There are a few keys that are used internally that will be overwritten when added to user supplied metadata, this list can be found in the #call method of PaulBunyan::JSONFormatter.

Seeing what your server logs will look like in the console

To do this set PB_DISABLE_CONSOLE_OVERRIDE in your environment: PB_DISABLE_CONSOLE_OVERRIDE=1 bundle exec rails c

paul_bunyan's People

Contributors

miquella avatar tpickett66 avatar wbhumphrey avatar mziwisky avatar ccutrer avatar danielbayerlein avatar rustybailey avatar simonista avatar

Stargazers

Classic Values avatar

Watchers

 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.