Sha256: e40f4247ab9ddc3ab6c59046e6e77c49fe669606a5ea72cc51f526449553d2ea

Contents?: true

Size: 1003 Bytes

Versions: 230

Compression:

Stored size: 1003 Bytes

Contents

/**
 * Usage: logg(someObject, 'label')
 *
 * This development-grade logger can be used instead of console.log() with some advantages:
 * * It encourages consistent labeling of logs. By labeling each log line, you can have dozens of log lines
 * written per action, and still know which log line comes from where.
 * The recommended label is the component name, or function name.
 * * If the label is present, the logged object is placed in the window, allowing you to inspect it in the console. The
 * label becomes the name of the object (stripped to [0-9a-zA-Z\-_] chars). If you're logging a function, you can execute it.
 * If you log more than one thing, they can interact, allowing you to validate control flow.
 * * the logger can be turned off by making this function simply return.
 */
 function logg (a, b="", c=null) {
  c = "string" === typeof c ? c : b.replace(/\W/g, "");
  if (c.length > 0) {
    window[c] = a;
  }

  console.log(`+++ ${b}:`, a); // eslint-disable-line no-console
};

Version data entries

230 entries across 230 versions & 1 rubygems

Version Path
ish_manager-0.1.8.496 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.495 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.494 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.493 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.492 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.491 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.490 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.489 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.488 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.487 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.486 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.485 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.484 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.483 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.482 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.481 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.480 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.479 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.478 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.477 app/assets/javascripts/ish_manager/shared.js