Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Aug 4, 2022
1 parent 5711b00 commit 943030e
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 68 deletions.
31 changes: 24 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
{
"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"
}
}
4 changes: 1 addition & 3 deletions dist/pilogger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ export declare const tags: {
debug: string;
console: string;
};
export declare function dateFormat(dt: string): void;
export declare function ringLength(): void;
export declare function print(...messages: any[]): void;
export declare function logFile(file: string): void;
export declare function accessFile(file: string): void;
export declare function clientFile(file: string): 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 assert(res: any, exp: any, ...messages: string[]): Promise<void>;
export declare function access(...messages: any[]): Promise<void>;
export declare function client(...messages: any[]): Promise<void>;
export declare function configure(userOptions: Partial<Options>): void;
Expand Down
2 changes: 1 addition & 1 deletion dist/pilogger.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 16 additions & 20 deletions dist/pilogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ var __copyProps = (to, from, except, desc) => {
}
return to;
};
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) {
"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();
}(exports, function() {
Expand Down Expand Up @@ -244,7 +247,6 @@ __export(pilogger_exports, {
configure: () => configure,
console: () => console,
data: () => data,
dateFormat: () => dateFormat,
debug: () => debug,
error: () => error,
fatal: () => fatal,
Expand All @@ -255,7 +257,6 @@ __export(pilogger_exports, {
options: () => options,
print: () => print,
ring: () => ring,
ringLength: () => ringLength,
state: () => state,
tags: () => tags,
timed: () => timed,
Expand Down Expand Up @@ -791,12 +792,6 @@ var logger = new import_console.Console({
ignoreErrors: true,
inspectOptions
});
function dateFormat(dt) {
options.dateFormat = dt;
}
function ringLength() {
options.ringLength = 100;
}
function stringify(message) {
let str = "";
try {
Expand Down Expand Up @@ -828,39 +823,38 @@ function logFile(file) {
options.logFile = file;
streams.logFile = true;
streams.logStream = fs.createWriteStream(path.resolve(options.logFile || ""), { flags: "a" });
if (streams.logStream)
if (streams.logStream) {
streams.logStream.on("error", (e) => {
print(tags.error, "Cannot open application log", options.logFile, e);
streams.logFile = false;
});
}
}
function accessFile(file) {
if (typeof file !== "string")
return;
options.accessFile = file;
streams.accessFile = true;
streams.accessStream = fs.createWriteStream(path.resolve(options.accessFile), { flags: "a" });
if (streams.accessStream)
if (streams.accessStream) {
streams.accessStream.on("error", (e) => {
print(tags.error, "Cannot open application log", options.accessFile, e);
streams.accessFile = false;
});
}
}
function clientFile(file) {
if (typeof file !== "string")
return;
options.clientFile = file;
streams.clientFile = true;
streams.clientStream = fs.createWriteStream(path.resolve(options.clientFile), { flags: "a" });
if (streams.clientStream)
if (streams.clientStream) {
streams.clientStream.on("error", (e) => {
print(tags.error, "Cannot open application log", options.clientFile, e);
streams.clientFile = false;
});
}
async function assert(res, exp, ...messages) {
if (res !== exp)
log("assert", ...messages, { res, exp });
}
}
async function timed(t0, ...messages) {
if (arguments.length < 2) {
Expand Down Expand Up @@ -894,6 +888,10 @@ async function log(tag, ...messages) {
if (ring.length > options.ringLength)
ring.shift();
}
async function assert(res, exp, ...messages) {
if (res !== exp)
log("assert", ...messages, { res, exp });
}
async function access(...messages) {
const time = (0, import_dayjs.default)(Date.now()).format(options.dateFormat);
if (streams.accessFile && streams.accessStream)
Expand Down Expand Up @@ -975,7 +973,6 @@ var console = (...message) => log("console", ...message);
configure,
console,
data,
dateFormat,
debug,
error,
fatal,
Expand All @@ -986,7 +983,6 @@ var console = (...message) => log("console", ...message);
options,
print,
ring,
ringLength,
state,
tags,
timed,
Expand Down
Loading

0 comments on commit 943030e

Please sign in to comment.