Skip to content

Instantly share code, notes, and snippets.

@rpivo
Last active August 18, 2021 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpivo/b4b968edbe513d965e1449c737a2559f to your computer and use it in GitHub Desktop.
Save rpivo/b4b968edbe513d965e1449c737a2559f to your computer and use it in GitHub Desktop.
JavaScript Logger

JavaScript Logger

 function log(lg) {
   const argName = Object.keys({ ...lg }).shift();
   console.info(`${argName}: %c${lg[argName]}`, 'color:#3EC5FF');
 }

 function getFormattedDate() {
   const date = new Date();
   const str =
     date.getFullYear() +
     '-' +
     (date.getMonth() + 1) +
     '-' +
     date.getDate() +
     ' ' +
     date.getHours() +
     ':' +
     date.getMinutes() +
     ':' +
     date.getSeconds() +
     ':' +
     date.getMilliseconds();

   return str;
 }

 console.info(`%c-----> ${getFormattedDate()}`, 'color:green');
 log({ activeLookbackId });
 log({ highlightedLookbackIds });
 log({ selector });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment