0.02
No commit activity in last 3 years
No release in over 3 years
Allows you to log to the console.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

The console.log gem allows you to log to the Javascript console from ruby/rails apps.

Usage

  1. Call console.log in rails.

    def load_user
      user = User.where(email: 'foo@bar.com')
      console.log "User: ", user
      user
    end
  2. Open your browser's developer console.

    Screen shot

  3. (optional) Scream with delight!

Installation

  1. Add gem "console.log" to your Gemfile.

    gem "console.log" # makes console.log available in ruby
  2. Bundle install

    bundle install

Reference

console.log

See the full documentation for console.log, which shows you how to use colour and various other formatting tweaks.

console.warn

If you want a little yellow triangle beside your message, call console.warn instead of console.log.

console.error

If you want your text to be bright red, call console.error instead of console.log.

Why??

I wrote it to solve 2 problems:

  1. It's hard to use rails logs for debugging because they're noisy, or (if you use something like pow) completely hidden. Using console.log lets you easily see only log messages in this request.
  2. When working on the js for Bugsnag I kept accidentally typing console.log into Rails. Now that works!

License

console.log is licensed under the MIT license, see LICENSE.MIT for details. Contributions and Bug Reports welcome!