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

logger3000

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logger3000 - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

35

index.js
const path = require('path');
const { fileURLToPath } = require('url');
const assert = require('assert');

@@ -18,5 +19,8 @@ const { NODE_ENV, PROD_PRINT_TIMESTAMP = false } = process.env;

if (!isProd) {
pinoOpts.prettyPrint = {
translateTime: 'SYS:standard',
errorProps: '*'
pinoOpts.transport = {
target: 'pino-pretty',
options: {
translateTime: 'SYS:standard',
errorProps: '*'
}
};

@@ -34,3 +38,3 @@ }

function toCategory(fileName) {
function toCategory (fileName) {
const args = [process.cwd()];

@@ -49,11 +53,11 @@ if (isProd) {

class Logger {
constructor(category) {
constructor (category) {
this.category = category;
}
_getMsg(level, msg) {
_getMsg (level, msg) {
return [level, this.category, msg].join(' - ');
}
_log(level, msg = '', arg1, arg2, arg3, arg4, arg5, arg6) {
_log (level, msg = '', arg1, arg2, arg3, arg4, arg5, arg6) {
msg = this._getMsg(level, msg);

@@ -84,3 +88,3 @@

*/
info({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) {
info ({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) {
this._log('INFO', msg, arg1, arg2, arg3, arg4, arg5, arg6);

@@ -109,3 +113,3 @@ }

*/
debug({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) {
debug ({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) {
this._log('DEBUG', msg, arg1, arg2, arg3, arg4, arg5, arg6);

@@ -139,3 +143,3 @@ }

*/
error({ error, msg, arg1, arg2, arg3, arg4 }) {
error ({ error, msg, arg1, arg2, arg3, arg4 }) {
assert(error, 'Error instance not exists.');

@@ -162,2 +166,13 @@ msg = this._getMsg('ERROR', msg);

exports.getLoggerESM = (importMetaURL) => {
const fileName = fileURLToPath(importMetaURL);
const category = toCategory(fileName);
let instance;
if (!_loggerInstances[category]) {
instance = Object.freeze(new Logger(category));
}
_loggerInstances[category] = instance;
return instance;
};
/**

@@ -164,0 +179,0 @@ * Configure dev & prod dirs for logging.

{
"name": "logger3000",
"version": "0.2.0",
"version": "1.0.0",
"description": "logger util",
"main": "index.js",
"scripts": {
"lint": "eslint *.js",
"lint": "npx semistandard --fix",
"test": "npm run lint"

@@ -17,23 +17,8 @@ },

"dependencies": {
"pino": "^6.3.2",
"pino-pretty": "^4.0.0"
"pino": "^8.4.2",
"pino-pretty": "^9.1.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^7.2.0",
"eslint-config-lil": "^1.0.6",
"eslint-config-prettier": "^6.11.0",
"eslint-config-xo-space": "^0.25.0",
"eslint-plugin-prettier": "^3.1.3",
"prettier": "^2.0.5"
},
"eslintConfig": {
"extends": [
"lil"
]
},
"prettier": {
"printWidth": 120,
"singleQuote": true
"semistandard": "^16.0.1"
}
}
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