@turbowarp/nanolog 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.js +8 -26
- package/package.json +1 -1
- package/test.js +0 -2
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- Does not use leading-zero octal literals (syntax error in strict mode)
|
|
7
7
|
- Does not interact with local storage, cookies, etc. (minilog does)
|
|
8
8
|
- Uses the default log styles from your browser; doesn't try to be smart
|
|
9
|
+
- No wrapper functions, so stack traces from your browser always point to the right spot
|
|
9
10
|
|
|
10
11
|
```js
|
|
11
12
|
const nanolog = require('@turbowarp/nanolog');
|
package/index.js
CHANGED
|
@@ -13,40 +13,22 @@ const INFO = `${CYAN}info${RESET}`;
|
|
|
13
13
|
const WARN = `${YELLOW}warn${RESET}`;
|
|
14
14
|
const ERROR = `${RED}error${RESET}`;
|
|
15
15
|
|
|
16
|
-
let enabled = false;
|
|
17
|
-
|
|
18
16
|
const createLog = (namespace = '') => {
|
|
19
17
|
const log = (childNamespace) => createLog(namespace ? `${namespace} ${childNamespace}` : childNamespace);
|
|
20
18
|
|
|
21
19
|
const formattedNamespace = namespace ? [`${GRAY}${namespace}${RESET}`] : [];
|
|
22
20
|
|
|
23
|
-
log.debug = log.log = (...
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
log.info = (...args) => {
|
|
28
|
-
if (enabled) console.info(...formattedNamespace, INFO, ...args);
|
|
29
|
-
return log;
|
|
30
|
-
};
|
|
31
|
-
log.warn = (...args) => {
|
|
32
|
-
if (enabled) console.warn(...formattedNamespace, WARN, ...args);
|
|
33
|
-
return log;
|
|
34
|
-
};
|
|
35
|
-
log.error = (...args) => {
|
|
36
|
-
if (enabled) console.error(...formattedNamespace, ERROR, ...args);
|
|
37
|
-
return log;
|
|
38
|
-
};
|
|
21
|
+
log.debug = log.log = console.debug.bind(console, ...formattedNamespace, DEBUG);
|
|
22
|
+
log.info = console.log.bind(console, ...formattedNamespace, INFO)
|
|
23
|
+
log.warn = log.warning = console.warn.bind(console, ...formattedNamespace, WARN)
|
|
24
|
+
log.error = console.error.bind(console, ...formattedNamespace, ERROR);
|
|
39
25
|
|
|
40
26
|
return log;
|
|
41
27
|
};
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
createLog.disable = () => {
|
|
48
|
-
enabled = false;
|
|
49
|
-
return createLog;
|
|
50
|
-
};
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated does nothing
|
|
31
|
+
*/
|
|
32
|
+
createLog.enable = createLog.disable = () => {};
|
|
51
33
|
|
|
52
34
|
module.exports = createLog;
|
package/package.json
CHANGED