[![Gem Version](https://badge.fury.io/rb/delogger.svg)](https://badge.fury.io/rb/delogger) # Delogger This gem is a simple wrapper for the browser's console. It can be turned off both globally (e.x. production environment) and locally. It also supports CSS formatting. ![Demo](/images/demo.png?raw=true) ## Getting Started ### Rails: Add the gem to your Gemfile: ```ruby gem 'delogger' ``` Add this to your `application.js`: ``` //= require delogger ``` And `application.css`: ``` *= require delogger ``` ### Without Rails: Include `vendor/assets/javascripts/delogger.js` and `vendor/assets/stylesheets/delogger.css` into your application. ## Usage First, DeLogger has to be initialized: ```js logger = new DeLogger ``` See also: [options](#options). By default, DeLogger is **disabled on the client side**. To enable it, use `logger.enable()` in your console. You can disable it again using `logger.disable()`. DeLogger supports same output methods as console: - `log`, `debug`: ![debug][/images/debug.png?raw=true] - `info`: ![info][/images/info.png?raw=true] - `warn`: ![warn][/images/warn.png?raw=true] - `error`: ![error][/images/error.png?raw=true] ## Formatting DeLogger supports string formatting. Syntax: `"(my text).class1.class2"`. Supported classes: `badge`, `bold`, `italic`. See also: [color classes](#color-classes). Example: ```js logger.log("(MyClass#myMethod).badge.italic (@akxcv).badge.orange (bold).bold", { foo: 'bar' }) ``` ![Example output](/images/formatting.png?raw=true) ## Color classes DeLogger supports following color classes (both for badges and normal text): - `.blue` - `.orange` - `.red` - `.green` - `.cyan` - `.yellow` - `.gray` - `.brown` - `.purple` - `.pink` ## Adding custom / overriding existing styles All styles are declared in a stylesheet and thus are easily extensible. See [`assets/stylesheets/delogger.scss`](assets/stylesheets/delogger.scss). At the moment, only these attributes are supported: `margin-left`, `color`, `background-color`, `border-radius`, `padding`, `font-weight`, `font-style`. ## Development Modify files in the `assets` folder, compile them afterwards using `./bin/compile`. ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/akxcv/delogger. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).