@imqueue/async-logger 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/async-logger",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "Configurable async logger over winston for @imqueue services",
5
5
  "keywords": [
6
6
  "logger",
@@ -8,60 +8,25 @@
8
8
  "imqueue",
9
9
  "services"
10
10
  ],
11
- "main": "index.js",
12
- "dependencies": {
13
- "@imqueue/core": "^2.0.11",
14
- "winston": "^3.17.0",
15
- "winston-transport": "^4.9.0"
16
- },
17
- "devDependencies": {
18
- "@types/chai": "^5.2.2",
19
- "@types/mocha": "^10.0.10",
20
- "@types/mock-require": "^3.0.0",
21
- "@types/node": "^24.3.1",
22
- "@types/sinon": "^17.0.4",
23
- "@typescript-eslint/eslint-plugin": "^8.42.0",
24
- "@typescript-eslint/parser": "^8.42.0",
25
- "@typescript-eslint/typescript-estree": "^8.42.0",
26
- "chai": "^6.0.1",
27
- "coveralls-next": "^5.0.0",
28
- "eslint": "^9.34.0",
29
- "glob": "^11.0.3",
30
- "minimist": "^1.2.8",
31
- "mocha": "^11.7.2",
32
- "mocha-lcov-reporter": "^1.3.0",
33
- "mock-require": "^3.0.3",
34
- "npm-scripts-help": "^0.8.0",
35
- "nyc": "^17.1.0",
36
- "open": "^10.2.0",
37
- "sinon": "^21.0.0",
38
- "source-map-support": "^0.5.21",
39
- "ts-node": "^10.9.2",
40
- "typedoc": "^0.28.12",
41
- "typedoc-plugin-as-member-of": "^1.0.2",
42
- "typedoc-plugin-markdown": "^4.8.1",
43
- "typescript": "^5.9.2"
44
- },
45
11
  "scripts": {
46
- "prepublishOnly": "npm run build",
47
- "test": "echo \"Error: no test specified\" && exit 0",
48
- "clean:ts": "find . -name '*.ts' -not -wholename '*node_modules*' -not -wholename '*.d.ts' -type f -delete",
49
- "clean:dts": "find . -name '*.d.ts' -not -wholename '*node_modules*' -type f -delete",
50
- "clean:map": "find . -name '*.js.map' -not -wholename '*node_modules*' -type f -delete",
51
- "clean:js": "find . -name '*.js' -not -wholename '*node_modules*' -not -wholename '*bin*' -type f -delete",
52
- "clean:build": "rm -rf ./node_modules/@types ; find . -name '*.js.map' -type f -delete ; find . -name '*.ts' -type f -delete",
53
- "clean:test": "rm -rf .nyc_output coverage",
54
- "clean:doc": "rm -rf docs",
55
- "clean:wiki": "rm -rf wiki",
56
- "clean": "npm run clean:test ; npm run clean:dts ; npm run clean:map ; npm run clean:js ; npm run clean:doc ; npm run clean:wiki",
57
- "build": "tsc",
58
- "mocha": "nyc mocha",
59
- "show:doc": "/usr/bin/env node -e \"require('open')('file://`pwd`/docs/index.html',{wait:false});\"",
60
- "doc": "npm run clean && typedoc --excludePrivate --excludeExternals --hideGenerator --exclude \"**/+(debug|test|node_modules|docs|coverage|.nyc_output|examples)/**/*\" --out ./docs --plugin typedoc-plugin-as-member-of . && npm run show:doc",
61
- "help": "npm-scripts-help"
12
+ "clean-compiled": "npm run clean-js && npm run clean-typedefs && npm run clean-maps",
13
+ "build": "npm run clean-compiled && tsc",
14
+ "prepare": "npm run build",
15
+ "lint": "oxlint",
16
+ "format": "oxfmt \"index.ts\" \"src/**/*.ts\" \"test/**/*.ts\"",
17
+ "format:check": "oxfmt --check \"index.ts\" \"src/**/*.ts\" \"test/**/*.ts\"",
18
+ "test": "npm run build && node --test --test-timeout=15000 $(find test -name '*.spec.js')",
19
+ "test-coverage": "npm run build && node --enable-source-maps --test --experimental-test-coverage --test-timeout=15000 $(find test -name '*.spec.js')",
20
+ "test-lcov": "npm run build && mkdir -p coverage && node --enable-source-maps --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-timeout=15000 $(find test -name '*.spec.js'); node scripts/strip-comment-coverage.mjs coverage/lcov.info",
21
+ "test-coverage-html": "npm run test-lcov; genhtml coverage/lcov.info --output-directory coverage/html --ignore-errors inconsistent,corrupt,format,mismatch && echo \"Coverage report: file://$(pwd)/coverage/html/index.html\"",
22
+ "test-dev": "npm run test && npm run clean-js && npm run clean-typedefs && npm run clean-maps",
23
+ "clean-typedefs": "find . -name '*.d.ts' -not -wholename '*node_modules*' -type f -delete",
24
+ "clean-maps": "find . -name '*.js.map' -not -wholename '*node_modules*' -type f -delete",
25
+ "clean-js": "find . -name '*.js' -not -wholename '*node_modules*' -type f -delete",
26
+ "clean-tests": "rm -rf .nyc_output coverage",
27
+ "clean-doc": "rm -rf docs",
28
+ "clean": "npm run clean-tests && npm run clean-typedefs && npm run clean-maps && npm run clean-js && npm run clean-doc"
62
29
  },
63
- "author": "imqueue.com <support@imqueue.com>",
64
- "license": "GPL-3.0-only",
65
30
  "repository": {
66
31
  "type": "git",
67
32
  "url": "git://github.com/imqueue/async-logger.git"
@@ -69,5 +34,20 @@
69
34
  "bugs": {
70
35
  "url": "https://github.com/imqueue/async-logger/issues"
71
36
  },
72
- "homepage": "https://github.com/imqueue/async-logger"
37
+ "homepage": "https://github.com/imqueue/async-logger",
38
+ "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
39
+ "license": "GPL-3.0-only",
40
+ "dependencies": {
41
+ "@imqueue/core": "^3.1.0",
42
+ "winston": "^3.19.0",
43
+ "winston-transport": "^4.9.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^24.9.1",
47
+ "oxfmt": "0.57.0",
48
+ "oxlint": "1.72.0",
49
+ "typescript": "^7.0.2"
50
+ },
51
+ "main": "index.js",
52
+ "types": "index.d.ts"
73
53
  }
package/src/Logger.d.ts CHANGED
@@ -47,7 +47,7 @@ export declare class Logger implements ILogger {
47
47
  *
48
48
  * @type {WinstonLogger}
49
49
  */
50
- private readonly logger;
50
+ private readonly logger?;
51
51
  /**
52
52
  * Logger Ctor
53
53
  *
package/src/Logger.js CHANGED
@@ -7,6 +7,18 @@ const helpers_1 = require("./helpers");
7
7
  * Class Logger
8
8
  */
9
9
  class Logger {
10
+ /**
11
+ * Asynchronous console async-logger
12
+ *
13
+ * @type {ILogger}
14
+ */
15
+ static console = {
16
+ // oxlint-disable-next-line no-console -- forwarding is the API here
17
+ log: (...args) => setTimeout(() => console.log(...args)),
18
+ info: (...args) => setTimeout(() => console.info(...args)),
19
+ warn: (...args) => setTimeout(() => console.warn(...args)),
20
+ error: (...args) => setTimeout(() => console.error(...args)),
21
+ };
10
22
  /**
11
23
  * @description
12
24
  * Configuring options of async-logger
@@ -20,6 +32,12 @@ class Logger {
20
32
  defaultMeta: metadata || (0, helpers_1.defaultMetadata)(),
21
33
  };
22
34
  }
35
+ /**
36
+ * Winston based async-logger having different logging transports
37
+ *
38
+ * @type {WinstonLogger}
39
+ */
40
+ logger;
23
41
  /**
24
42
  * Logger Ctor
25
43
  *
@@ -97,20 +115,12 @@ class Logger {
97
115
  continue;
98
116
  }
99
117
  const transport = (0, helpers_1.getTransport)(options.type, options.options);
100
- this.logger.add(transport);
118
+ // the constructor always creates the winston logger before
119
+ // calling setupLogger(), the optional chaining only satisfies
120
+ // strict property-initialization analysis
121
+ this.logger?.add(transport);
101
122
  }
102
123
  }
103
124
  }
104
125
  exports.Logger = Logger;
105
- /**
106
- * Asynchronous console async-logger
107
- *
108
- * @type {ILogger}
109
- */
110
- Logger.console = {
111
- log: (...args) => setTimeout(() => console.log(...args)),
112
- info: (...args) => setTimeout(() => console.info(...args)),
113
- warn: (...args) => setTimeout(() => console.warn(...args)),
114
- error: (...args) => setTimeout(() => console.error(...args)),
115
- };
116
126
  //# sourceMappingURL=Logger.js.map
@@ -32,7 +32,7 @@ function transportsConfig() {
32
32
  .replace(RX_VERSION, version));
33
33
  }
34
34
  catch (err) {
35
- throw new TypeError(`Logger: can not parse transports config: ${err.stack ? err.stack : err.message}`);
35
+ throw new TypeError(`Logger: can not parse transports config: ${err instanceof Error ? err.stack || err.message : String(err)}`);
36
36
  }
37
37
  }
38
38
  /**
@@ -48,7 +48,7 @@ function defaultMetadata() {
48
48
  .replace(RX_VERSION, version));
49
49
  }
50
50
  catch (err) {
51
- throw new TypeError(`Logger: can not parse metadata: ${err.stack ? err.stack : err.message}`);
51
+ throw new TypeError(`Logger: can not parse metadata: ${err instanceof Error ? err.stack || err.message : String(err)}`);
52
52
  }
53
53
  }
54
54
  //# sourceMappingURL=env.js.map
package/eslint.config.mjs DELETED
@@ -1,58 +0,0 @@
1
- import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
- import globals from "globals";
3
- import tsParser from "@typescript-eslint/parser";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import js from "@eslint/js";
7
- import { FlatCompat } from "@eslint/eslintrc";
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const compat = new FlatCompat({
12
- baseDirectory: __dirname,
13
- recommendedConfig: js.configs.recommended,
14
- allConfig: js.configs.all
15
- });
16
-
17
- export default [
18
- ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
19
- {
20
- plugins: {
21
- "@typescript-eslint": typescriptEslint,
22
- },
23
-
24
- languageOptions: {
25
- globals: {
26
- ...globals.node,
27
- },
28
-
29
- parser: tsParser,
30
- },
31
-
32
- rules: {
33
- "max-len": ["error", {
34
- code: 80,
35
- }],
36
-
37
- "new-parens": "error",
38
- "no-caller": "error",
39
- "no-cond-assign": ["error", "always"],
40
- "no-multiple-empty-lines": "off",
41
-
42
- quotes: ["error", "single", {
43
- avoidEscape: true,
44
- }],
45
-
46
- "arrow-parens": "off",
47
- "no-bitwise": "off",
48
- "sort-keys": "off",
49
- "no-console": "off",
50
- "max-classes-per-file": "off",
51
- "no-unused-expressions": "off",
52
- "@typescript-eslint/interface-name-prefix": "off",
53
- "comma-dangle": ["error", "always-multiline"],
54
- "@typescript-eslint/no-namespace": "off",
55
- "@typescript-eslint/no-extraneous-class": "off",
56
- },
57
- },
58
- ];