Sha256: ca36ea7556d2ca27d8324270d921fc41c6676a0eee97c8bba89d7a6c27be3c31

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 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.
 */
 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

4 entries across 4 versions & 1 rubygems

Version Path
ish_manager-0.1.8.253 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.252 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.251 app/assets/javascripts/ish_manager/shared.js
ish_manager-0.1.8.250 app/assets/javascripts/ish_manager/shared.js