Giter Club home page Giter Club logo

jquery.debug's Introduction

jquery.debug Build Status Code Climate

This plugin helps managing debugging in javascript. It looks for a url param or cookie and prints conditional to the browser console. it is useful if you want to log debug informations to the browser console on development hosts per default, but not in production. You can enable the debug mode in production via a url parameter.

Installation

bower install jquery.debug

Usage

javascript

$.debug(true);
$.debug.log('msg'); //prints to console

$.debug(false);
$.debug.log('msg'); //doesnt print to console

//sets 192.123.* hosts as development hosts
$.debug({developmentHosts: ['192.123.']})

It also exposes the class JQueryDebug for manual instantiating.

coffee script

$.debug true
$.debug.log 'msg' #prints to console

$.debug false
$.debug.log 'msg' #doesnt print to console

#adds 192.123.* hosts to development hosts
$.debug developmentHosts: [ '192.123.' ]

It also exposes the class JQueryDebug for manual instantiating and extending.

Parameter

developmentHosts

List of hosts or host-substrings for development host detection. Default is:

  • 127.0
  • 192.168
  • localhost

urlParam

Name of the url param to watch for, default is 'debug'. You van use:

  • ?debug=0
  • ?debug=false
  • ?debug=1
  • ?debug=true

cookieName

Name of the cookie for debug storing, default is 'debug'.

Functions

$.debug(configuration|debugMode|null)

Initialize the plugin.

  • with a configuration object.
  • or sets the debug mode if one of ['1', 1, 'true', true, '0', 0, 'false', false] is given.
  • If no parameter is given it returns the actual debug mode.

$.debug.config (options)

Updates the configuration.

$.debug.enable

Enables debug mode.

$.debug.disable

Disables debug mode.

$.debug.isEnabled

Returns the actual debug mode.

$.debug.setDebugMode (state)

Set the debug mode and stores it in the cookie. Valid values are:

  • 0
  • '0'
  • false
  • 'false'
  • 1
  • '1'
  • true
  • 'true'

$.debug.isDevelopment

Tells if the actual host is a development host.

$.debug.isProduction

Tells if the actual host is a production host.

$.debug.log (msg)

Logs a massage to the browser console if in debug mode.

$.debug.debug (msg)

Logs a debug massage to the browser console if in debug mode.

$.debug.error (msg)

Logs a error massage to the browser console if in debug mode.

$.debug.info (msg)

Logs a info massage to the browser console if in debug mode.

$.debug.warn (msg)

Logs a warning massage to the browser console if in debug mode.

$.debug.alert (msg)

Alerts a massage if in debug mode.

Dependencies

Resources

Authors

Tom Hanoldt

Contributing

Check out the Contributing Guidelines

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.