Skip to content

the-trash/the_log

Repository files navigation

TheLog

Take care of your joints. Write less, do same.

Replace console.log with log in your Rails App

Installation

Add this line to your application's Gemfile:

gem 'the_log'

And then execute:

bundle

Or install it yourself as:

gem install the_log

Usage

application.js

//= require jquery
//= require the_log

layouts/application.html.haml

!!!
%html{ data: { the_log: Rails.env.development? } }
%head
  %title My Application
  = stylesheet_link_tag    :application, media: :all
  = javascript_include_tag :application
  = csrf_meta_tags

%body
  / ....

Into your Browser Console

log('Hello World!')

Into your CoffeeScript code

# DOM 'ready' event
$ ->
  log 'Hello World!'

TheLog and Production env

Nobody wants to see log messages in web console in production mode. You can configure visibility of log messages with data-the-log param

%AnyTag{ data: { the_log: Rails.env.development? } }

or you can switch it in JS console

TheLog.enable = true  // log messages will be visible
TheLog.enable = false // there are no log messages

MIT licence

About

Replace console.log with log in your Rails App

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published