-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore rename util.js to Logger.js and refactor functions to a class
- Loading branch information
1 parent
e1c20b3
commit d804139
Showing
3 changed files
with
44 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* | ||
* provide development utility functions for reporting errors, logging data and logging time | ||
*/ | ||
|
||
/* eslint-disable no-console */ | ||
export default class Logger { | ||
static #isProductionEnv = () => process.env.NODE_ENV === 'production'; | ||
|
||
static logError = (error) => { | ||
if (this.#isProductionEnv()) return; | ||
console.error(error); | ||
}; | ||
|
||
/** | ||
* | ||
* @param {...any} data | ||
* @returns {void} | ||
*/ | ||
static logInfo = (...data) => { | ||
if (this.#isProductionEnv()) return; | ||
|
||
console.log(...data); | ||
}; | ||
|
||
/** | ||
* | ||
* @param {String} label | ||
* @returns {Function} end and display time when called in non production environment | ||
*/ | ||
static logTime = (label) => { | ||
if (this.#isProductionEnv()) { | ||
return () => { | ||
// no-op} | ||
}; | ||
} | ||
console.time(label); | ||
return () => console.timeEnd(label); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.