@dodona/papyros
Version:
Scratchpad for multiple programming languages in the browser.
30 lines • 966 B
JavaScript
/**
* Enum representing the importance of a log message
* This is helpful for debugging while allowing filtering in production
*/
export var LogType;
(function (LogType) {
LogType[LogType["Debug"] = 0] = "Debug";
LogType[LogType["Error"] = 1] = "Error";
LogType[LogType["Important"] = 2] = "Important";
})(LogType || (LogType = {}));
const ENVIRONMENT = process.env.NODE_ENV || "development";
// Log everything in development
const SHOULD_LOG = ENVIRONMENT !== "production";
/**
* Helper method to log useful information at runtime
* @param {LogType} logType The importance of this log message
* @param {any[]} args The data to log
*/
export function papyrosLog(logType, ...args) {
const doLog = SHOULD_LOG || logType !== LogType.Debug;
if (doLog) {
if (logType === LogType.Error) {
console.error(...args);
}
else {
console.log(...args);
}
}
}
//# sourceMappingURL=Logging.js.map