Skip to content

Commit 0e93d46

Browse files
committed
Add logger
1 parent 28ab412 commit 0e93d46

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/** Is debug logging on? */
2+
let isDebug = false;
3+
4+
/**
5+
* Turn on debug logging
6+
* @example
7+
* import { setDebug } from "curly";
8+
*
9+
* setDebug(true);
10+
*/
11+
export const setDebug = (value: boolean) => {
12+
isDebug = value;
13+
};
14+
15+
16+
/** Log warning */
17+
export const warn = (...args: unknown[]) => {
18+
console.warn(...args);
19+
};
20+
21+
/** Log if debugging is on */
22+
export const debug = (...args: unknown[]) => {
23+
if (isDebug) {
24+
console.debug(...args);
25+
}
26+
};

0 commit comments

Comments
 (0)