Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More →
Socket
Sign inDemoInstall
Socket

logmoji

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logmoji - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

package.json
{
"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;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡ī¸ by Socket Inc