1
Fork 0
tildes-reextended/source/utilities/logging.ts

22 lines
598 B
TypeScript
Raw Normal View History

/**
2023-06-25 10:00:43 +00:00
* Log something to the console under the debug level.
* @param thing The thing to log.
* @param force If true, ignores whether or not debug logging is enabled.
*/
export function log(thing: any, force = false): void {
2023-06-23 10:52:03 +00:00
let overrideStyle = "";
let prefix = "[TRX]";
if (force) {
2023-06-23 10:52:03 +00:00
prefix = "%c" + prefix;
overrideStyle = "background-color: #dc322f; margin-right: 9px;";
}
2023-06-23 10:52:03 +00:00
if (window.TildesReExtended?.debug || $dev || force) {
if (overrideStyle.length > 0) {
console.debug(prefix, overrideStyle, thing);
} else {
console.debug(prefix, thing);
}
}
}