Skip to content

Commit d2e2caa

Browse files
committed
feat: add new log types
1 parent 77ebc1b commit d2e2caa

6 files changed

Lines changed: 39 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logmoji",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "🪵 Very small logging package with emojis for node.js",
55
"main": "src/index.js",
66
"types": "src/index.d.ts",

src/config.class.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ interface ILogSymbols {
55
info: string;
66
warn: string;
77
log: string;
8+
alert: string;
9+
crit: string;
10+
warning: string;
11+
debug: string;
12+
silly: string;
813
}
914

1015
export interface ConfigOptions {

src/config.class.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class ConfigClass {
1111
error: this.validateEmoji(logSymbols?.error) || "🚨",
1212
info: this.validateEmoji(logSymbols?.info) || "📄",
1313
log: this.validateEmoji(logSymbols?.log) || "📄",
14+
alert: this.validateEmoji(logSymbols?.alert) || "😡",
15+
crit: this.validateEmoji(logSymbols?.crit) || "😱",
16+
warning: this.validateEmoji(logSymbols?.warning) || "⚠️",
17+
debug: this.validateEmoji(logSymbols?.debug) || "🛠️",
18+
silly: this.validateEmoji(logSymbols?.silly) || "🤪",
1419
},
1520
logColors: {
1621
success: "\x1b[32m",
@@ -19,6 +24,11 @@ class ConfigClass {
1924
error: "\x1b[31m",
2025
info: "\x1b[0m",
2126
log: "\x1b[0m",
27+
alert: "\x1b[91m",
28+
crit: "\x1b[35m",
29+
warning: "\x1b[33m",
30+
debug: "\x1b[90m",
31+
silly: "\x1b[2m",
2232
clear: "\x1b[0m",
2333
},
2434
};

src/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ export interface Logger {
77
info: (...args: any[]) => void;
88
warn: (...args: any[]) => void;
99
log: (...args: any[]) => void;
10+
alert: (...args: any[]) => void;
11+
crit: (...args: any[]) => void;
12+
warning: (...args: any[]) => void;
13+
debug: (...args: any[]) => void;
14+
silly: (...args: any[]) => void;
1015
}
1116

12-
type LogLevel = 'success' | 'fail' | 'error' | 'info' | 'warn' | 'log';
17+
type LogLevel = 'success' | 'fail' | 'error' | 'info' | 'warn' | 'log' | 'alert' | 'crit' | 'warning' | 'debug' | 'silly';
1318

1419
export default function createLogger(params?: ConfigOptions): Logger;
1520

src/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const createLogger = (params) => {
1616
error: console.error,
1717
info: console.info,
1818
log: console.log,
19+
alert: console.error,
20+
crit: console.error,
21+
warning: console.warn,
22+
debug: console.log,
23+
silly: console.log,
1924
};
2025

2126
const timestamp = config?.timestamp ? getDateLog() : "";
@@ -37,6 +42,11 @@ const createLogger = (params) => {
3742
info: (...args) => log("info", context, ...args),
3843
warn: (...args) => log("warn", context, ...args),
3944
log: (...args) => log("log", context, ...args),
45+
alert: (...args) => log("alert", context, ...args),
46+
crit: (...args) => log("crit", context, ...args),
47+
warning: (...args) => log("warning", context, ...args),
48+
debug: (...args) => log("debug", context, ...args),
49+
silly: (...args) => log("silly", context, ...args),
4050
});
4151

4252
return {
@@ -46,6 +56,11 @@ const createLogger = (params) => {
4656
info: (...args) => log("info", "", ...args),
4757
warn: (...args) => log("warn", "", ...args),
4858
log: (...args) => log("log", "", ...args),
59+
alert: (...args) => log("alert", "", ...args),
60+
crit: (...args) => log("crit", "", ...args),
61+
warning: (...args) => log("warning", "", ...args),
62+
debug: (...args) => log("debug", "", ...args),
63+
silly: (...args) => log("silly", "", ...args),
4964
createContext,
5065
};
5166
};

0 commit comments

Comments
 (0)