Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "logmoji", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "đĒĩ Very small logging package with emojis for node.js", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -0,3 +1,14 @@ | ||
interface ILogSymbols { | ||
success: string; | ||
fail: string; | ||
error: string; | ||
info: string; | ||
warn: string; | ||
log: string; | ||
} | ||
export interface ConfigOptions { | ||
timestamp?: false | true | ||
disablePrefixText?: false | true | ||
logSymbols?: ILogSymbols | ||
} |
class ConfigClass { | ||
constructor({ timestamp }) { | ||
constructor({ timestamp, disablePrefixText, logSymbols }) { | ||
this.config = { | ||
timestamp: timestamp || false, | ||
isLoggingDisabled: process.env.LOG || false, | ||
disablePrefixText: disablePrefixText || false, | ||
logSymbols: { | ||
success: this.validateEmoji(logSymbols?.success) || "â ", | ||
fail: this.validateEmoji(logSymbols?.fail) || "đ", | ||
warn: this.validateEmoji(logSymbols?.warn) || "đ ", | ||
error: this.validateEmoji(logSymbols?.error) || "đ¨", | ||
info: this.validateEmoji(logSymbols?.info) || "âšī¸", | ||
log: this.validateEmoji(logSymbols?.log) || "đ", | ||
}, | ||
}; | ||
} | ||
validateEmoji(emoji) { | ||
const emojiRegex = /\p{Emoji}/u; | ||
return emojiRegex.test(emoji) ? emoji : null; | ||
} | ||
getConfig() { | ||
@@ -10,0 +24,0 @@ return this.config; |
@@ -8,12 +8,5 @@ const ConfigClass = require("./config.class"); | ||
const logSymbols = config.logSymbols; | ||
const log = (level, ...args) => { | ||
const logSymbols = { | ||
success: "â ", | ||
fail: "đ", | ||
warn: "đ ", | ||
error: "đ¨", | ||
info: "âšī¸", | ||
log: "đ", | ||
}; | ||
const logFunction = { | ||
@@ -32,3 +25,3 @@ success: console.info, | ||
if (isLoggingDisabled) return; | ||
logFunction[level](`${timestamp} ${logSymbols[level]} ${level.charAt(0).toUpperCase() + level.slice(1)}: `, ...args); | ||
logFunction[level](`${timestamp} ${logSymbols[level]}${config?.disablePrefixText ? "" : level.charAt(0).toUpperCase() + level.slice(1) + ": "}`, ...args); | ||
}; | ||
@@ -35,0 +28,0 @@ |
const getDateLog = () => { | ||
return `[${Date.now()}]`; | ||
return `[${new Date().toISOString()}]`; | ||
}; | ||
module.exports = getDateLog; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10840
95