Skip to content

Instantly share code, notes, and snippets.

@tkh44
Last active September 13, 2022 02:34

Revisions

  1. Kye Hohenberger revised this gist Mar 1, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions logWithLabel.js
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,19 @@
    const a = { foo: 'bar' };
    const b = 'I like cookies';

    export const logWithLabel = (content, label) => {
    export const logWithLabel = (content, label, collapsed = false) => {

    if (__DEVELOPMENT__) {
    content = Array.isArray(content) ? content : [content];

    console.groupCollapsed(label.toUpperCase());
    console[collapsed ? 'groupCollapsed' : 'group'](label.toUpperCase());
    content.forEach((c) => {

    if (Array.isArray(c) && Object.prototype.toString.call(c[0]) === '[object Object]') {
    return console.table(c, Object.keys(c[0]));
    }

    if (if (Object.prototype.toString.call(c) === '[object Object]') {
    if (Object.prototype.toString.call(c) === '[object Object]') {
    return console.dir(c);
    }

  2. Kye Hohenberger revised this gist Mar 1, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion logWithLabel.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ export const logWithLabel = (content, label) => {
    return console.table(c, Object.keys(c[0]));
    }

    if (isPlainObject(c)) {
    if (if (Object.prototype.toString.call(c) === '[object Object]') {
    return console.dir(c);
    }

  3. Kye Hohenberger revised this gist Mar 1, 2016. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion logWithLabel.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    const a = { foo: 'bar' };
    const b = 'I like cookies';

    export const logWithLabel = (content, label) => {

    if (__DEVELOPMENT__) {
    @@ -23,4 +26,6 @@ export const logWithLabel = (content, label) => {
    });
    console.groupEnd();
    }
    };
    };

    //logWithLabel([a, b], 'Received');
  4. Kye Hohenberger created this gist Mar 1, 2016.
    26 changes: 26 additions & 0 deletions logWithLabel.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    export const logWithLabel = (content, label) => {

    if (__DEVELOPMENT__) {
    content = Array.isArray(content) ? content : [content];

    console.groupCollapsed(label.toUpperCase());
    content.forEach((c) => {

    if (Array.isArray(c) && Object.prototype.toString.call(c[0]) === '[object Object]') {
    return console.table(c, Object.keys(c[0]));
    }

    if (isPlainObject(c)) {
    return console.dir(c);
    }

    let message = c;
    if (typeof c === 'string') {
    message = `"${c}"`;
    }

    console.log(message);
    });
    console.groupEnd();
    }
    };