@vladmandic/pilogger
Advanced tools
Comparing version 0.4.5 to 0.4.6
{ | ||
"globals": {}, | ||
"env": { | ||
"browser": false, | ||
"browser": true, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true, | ||
"es2020": true | ||
"es2022": true | ||
}, | ||
"parserOptions": { "ecmaVersion": 2020 }, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2022 | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"import", | ||
"json", | ||
"html" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"airbnb-base" | ||
"airbnb-base", | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:json/recommended-with-comments", | ||
"plugin:import/typescript" | ||
], | ||
"rules": { | ||
"max-len": [1, 275, 3], | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"import/no-extraneous-dependencies": "off", | ||
"no-param-reassign": "off", | ||
"no-restricted-syntax": "off" | ||
"no-restricted-syntax": "off", | ||
"object-curly-newline": "off", | ||
"radix": "off" | ||
} | ||
} |
@@ -44,4 +44,2 @@ /// <reference types="node" /> | ||
}; | ||
export declare function dateFormat(dt: string): void; | ||
export declare function ringLength(): void; | ||
export declare function print(...messages: any[]): void; | ||
@@ -51,4 +49,4 @@ export declare function logFile(file: string): void; | ||
export declare function clientFile(file: string): void; | ||
export declare function timed(t0: bigint, ...messages: string[]): Promise<void>; | ||
export declare function assert(res: any, exp: any, ...messages: string[]): Promise<void>; | ||
export declare function timed(t0: bigint, ...messages: string[]): Promise<void>; | ||
export declare function access(...messages: any[]): Promise<void>; | ||
@@ -55,0 +53,0 @@ export declare function client(...messages: any[]): Promise<void>; |
@@ -23,8 +23,11 @@ "use strict"; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// node_modules/.pnpm/dayjs@1.11.3/node_modules/dayjs/dayjs.min.js | ||
// node_modules/.pnpm/dayjs@1.11.4/node_modules/dayjs/dayjs.min.js | ||
var require_dayjs_min = __commonJS({ | ||
"node_modules/.pnpm/dayjs@1.11.3/node_modules/dayjs/dayjs.min.js"(exports, module2) { | ||
"node_modules/.pnpm/dayjs@1.11.4/node_modules/dayjs/dayjs.min.js"(exports, module2) { | ||
!function(t, e) { | ||
@@ -248,3 +251,2 @@ "object" == typeof exports && "undefined" != typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e(); | ||
data: () => data, | ||
dateFormat: () => dateFormat, | ||
debug: () => debug, | ||
@@ -260,3 +262,2 @@ error: () => error, | ||
ring: () => ring, | ||
ringLength: () => ringLength, | ||
state: () => state, | ||
@@ -797,8 +798,2 @@ tags: () => tags, | ||
}); | ||
function dateFormat(dt) { | ||
options.dateFormat = dt; | ||
} | ||
function ringLength() { | ||
options.ringLength = 100; | ||
} | ||
function stringify(message) { | ||
@@ -835,3 +830,3 @@ let str = ""; | ||
streams.logStream = fs.createWriteStream(path.resolve(options.logFile || ""), { flags: "a" }); | ||
if (streams.logStream) | ||
if (streams.logStream) { | ||
streams.logStream.on("error", (e) => { | ||
@@ -841,2 +836,3 @@ print(tags.error, "Cannot open application log", options.logFile, e); | ||
}); | ||
} | ||
} | ||
@@ -849,3 +845,3 @@ function accessFile(file) { | ||
streams.accessStream = fs.createWriteStream(path.resolve(options.accessFile), { flags: "a" }); | ||
if (streams.accessStream) | ||
if (streams.accessStream) { | ||
streams.accessStream.on("error", (e) => { | ||
@@ -855,2 +851,3 @@ print(tags.error, "Cannot open application log", options.accessFile, e); | ||
}); | ||
} | ||
} | ||
@@ -863,3 +860,3 @@ function clientFile(file) { | ||
streams.clientStream = fs.createWriteStream(path.resolve(options.clientFile), { flags: "a" }); | ||
if (streams.clientStream) | ||
if (streams.clientStream) { | ||
streams.clientStream.on("error", (e) => { | ||
@@ -869,7 +866,4 @@ print(tags.error, "Cannot open application log", options.clientFile, e); | ||
}); | ||
} | ||
} | ||
async function assert(res, exp, ...messages) { | ||
if (res !== exp) | ||
log("assert", ...messages, { res, exp }); | ||
} | ||
async function timed(t0, ...messages) { | ||
@@ -907,2 +901,6 @@ if (arguments.length < 2) { | ||
} | ||
async function assert(res, exp, ...messages) { | ||
if (res !== exp) | ||
log("assert", ...messages, { res, exp }); | ||
} | ||
async function access(...messages) { | ||
@@ -989,3 +987,2 @@ const time = (0, import_dayjs.default)(Date.now()).format(options.dateFormat); | ||
data, | ||
dateFormat, | ||
debug, | ||
@@ -1001,3 +998,2 @@ error, | ||
ring, | ||
ringLength, | ||
state, | ||
@@ -1004,0 +1000,0 @@ tags, |
{ | ||
"name": "@vladmandic/pilogger", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Simple Logger for NodeJS", | ||
@@ -31,6 +31,14 @@ "main": "dist/pilogger.js", | ||
"devDependencies": { | ||
"@types/node": "^18.0.4", | ||
"@types/node": "^18.6.3", | ||
"@typescript-eslint/eslint-plugin": "^5.32.0", | ||
"@typescript-eslint/parser": "^5.32.0", | ||
"@vladmandic/build": "^0.7.8", | ||
"chalk": "^5.0.1", | ||
"dayjs": "^1.11.3", | ||
"esbuild": "^0.14.49", | ||
"dayjs": "^1.11.4", | ||
"esbuild": "^0.14.53", | ||
"eslint": "8.21.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-html": "^7.1.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-json": "^3.1.0", | ||
"tslib": "^2.4.0", | ||
@@ -37,0 +45,0 @@ "typescript": "^4.7.4" |
@@ -28,5 +28,12 @@ import * as os from 'os'; | ||
timeStamp: true, | ||
} | ||
}; | ||
export type Streams = { logFile: boolean, accessFile: boolean, clientFile: boolean, logStream: fs.WriteStream | undefined, accessStream: fs.WriteStream | undefined, clientStream: fs.WriteStream | undefined }; | ||
export type Streams = { | ||
logFile: boolean, | ||
accessFile: boolean, | ||
clientFile: boolean, | ||
logStream: fs.WriteStream | undefined, | ||
accessStream: fs.WriteStream | undefined, | ||
clientStream: fs.WriteStream | undefined, | ||
}; | ||
const streams: Streams = { | ||
@@ -39,3 +46,3 @@ logFile: false, | ||
clientStream: undefined, | ||
} | ||
}; | ||
@@ -56,3 +63,3 @@ export type Tags = 'blank' | 'continue' | 'info' | 'warn' | 'data' | 'error' | 'fatal' | 'assert' | 'timed' | 'state' | 'verbose' | 'debug' | 'console'; | ||
debug: chalk.bgGray.redBright('DEBUG:'), | ||
console: chalk.gray('CONSOLE:') | ||
console: chalk.gray('CONSOLE:'), | ||
}; | ||
@@ -80,17 +87,5 @@ | ||
export function dateFormat(dt: string) { | ||
options.dateFormat = dt; | ||
} | ||
export function ringLength() { | ||
options.ringLength = 100; | ||
} | ||
function stringify(message: any) { | ||
let str = ''; | ||
try { | ||
str = JSON.stringify(message); | ||
} catch { | ||
// | ||
} | ||
try { str = JSON.stringify(message); } catch { /**/ } | ||
return str; | ||
@@ -121,6 +116,8 @@ } | ||
streams.logStream = fs.createWriteStream(path.resolve(options.logFile || ''), { flags: 'a' }); | ||
if (streams.logStream) streams.logStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.logFile, e); | ||
streams.logFile = false; | ||
}); | ||
if (streams.logStream) { | ||
streams.logStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.logFile, e); | ||
streams.logFile = false; | ||
}); | ||
} | ||
} | ||
@@ -133,6 +130,8 @@ | ||
streams.accessStream = fs.createWriteStream(path.resolve(options.accessFile), { flags: 'a' }); | ||
if (streams.accessStream) streams.accessStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.accessFile, e); | ||
streams.accessFile = false; | ||
}); | ||
if (streams.accessStream) { | ||
streams.accessStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.accessFile, e); | ||
streams.accessFile = false; | ||
}); | ||
} | ||
} | ||
@@ -145,12 +144,10 @@ | ||
streams.clientStream = fs.createWriteStream(path.resolve(options.clientFile), { flags: 'a' }); | ||
if (streams.clientStream) streams.clientStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.clientFile, e); | ||
streams.clientFile = false; | ||
}); | ||
if (streams.clientStream) { | ||
streams.clientStream.on('error', (e) => { | ||
print(tags.error, 'Cannot open application log', options.clientFile, e); | ||
streams.clientFile = false; | ||
}); | ||
} | ||
} | ||
export async function assert(res: any, exp: any, ...messages: string[]) { | ||
if (res !== exp) log('assert', ...messages, { res, exp }); | ||
} | ||
export async function timed(t0: bigint, ...messages: string[]) { | ||
@@ -163,5 +160,3 @@ if (arguments.length < 2) { | ||
let elapsed = 0; | ||
try { | ||
elapsed = parseInt((t1 - t0).toString()); | ||
} catch { /**/ } | ||
try { elapsed = parseInt((t1 - t0).toString()); } catch { /**/ } | ||
elapsed = Math.round(elapsed / 1000000); | ||
@@ -182,2 +177,6 @@ const time = dayjs(Date.now()).format(options.dateFormat); | ||
export async function assert(res: any, exp: any, ...messages: string[]) { | ||
if (res !== exp) log('assert', ...messages, { res, exp }); | ||
} | ||
export async function access(...messages: any[]) { | ||
@@ -184,0 +183,0 @@ const time = dayjs(Date.now()).format(options.dateFormat); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
68700
1378
14