Skip to content

Instantly share code, notes, and snippets.

@danielskapunk
Last active March 11, 2019 17:17
Show Gist options
  • Select an option

  • Save danielskapunk/65e394ff1ca577be710295fddc2207ef to your computer and use it in GitHub Desktop.

Select an option

Save danielskapunk/65e394ff1ca577be710295fddc2207ef to your computer and use it in GitHub Desktop.

Revisions

  1. danielskapunk revised this gist Mar 11, 2019. No changes.
  2. danielskapunk revised this gist Nov 17, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    {
    "name": "dconsole.js",
    "version": "0.1.0"
    }
  3. David Paul Rosser created this gist Aug 18, 2016.
    61 changes: 61 additions & 0 deletions console.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    /**
    * console wrapper with line numbers
    * Usage:
    * import * as c from 'console'
    * c.log('abc');
    *
    * Ref: https://matthewspencer.github.io/console-log/
    */

    /*eslint-disable */
    const slice = [].slice;
    const enabled = window.location.hostname.indexOf('localhost') !== -1;

    export const log = function log() {
    if (!window.console || !console.log) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.log, console);
    }();

    export const clear = function clear() {
    if (!window.console || !console.clear) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.clear, console);
    }();

    export const debug = function debug() {
    if (!window.console || !console.debug) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.debug, console);
    }();

    export const info = function info() {
    if (!window.console || !console.info) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.info, console);
    }();

    export const warn = function warn() {
    if (!window.console || !console.warn) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.warn, console);
    }();

    export const error = function error() {
    if (!window.console || !console.error) {
    return function() {};
    }
    if (!enabled) return function() {};
    return Function.prototype.bind.call(console.error, console);
    }();
    /*eslint-enable */