@imqueue/async-logger 3.0.1 → 3.1.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/index.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- import { Logger } from './src';
23
- export * from './src';
22
+ import { Logger } from './src/index.js';
23
+ export * from './src/index.js';
24
24
  declare const _default: Logger;
25
25
  export default _default;
package/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * I'm Queue Software Project
19
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -35,8 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
19
  * purchase a proprietary commercial license. Please contact us at
36
20
  * <support@imqueue.com> to get commercial licensing options.
37
21
  */
38
- const src_1 = require("./src");
39
- __exportStar(require("./src"), exports);
40
- // noinspection JSUnusedGlobalSymbols
41
- exports.default = new src_1.Logger();
22
+ import { Logger } from './src/index.js';
23
+ export * from './src/index.js';
24
+ export default new Logger();
42
25
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/async-logger",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "Configurable async logger over winston for @imqueue services",
5
5
  "keywords": [
6
6
  "logger",
@@ -38,7 +38,6 @@
38
38
  "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
39
39
  "license": "GPL-3.0-only",
40
40
  "dependencies": {
41
- "@imqueue/core": "^3.1.1",
42
41
  "winston": "^3.19.0",
43
42
  "winston-transport": "^4.9.0"
44
43
  },
@@ -49,5 +48,16 @@
49
48
  "typescript": "^7.0.2"
50
49
  },
51
50
  "main": "index.js",
52
- "types": "index.d.ts"
51
+ "types": "index.d.ts",
52
+ "type": "module",
53
+ "engines": {
54
+ "node": ">=22.12.0"
55
+ },
56
+ "exports": {
57
+ ".": {
58
+ "types": "./index.d.ts",
59
+ "default": "./index.js"
60
+ },
61
+ "./package.json": "./package.json"
62
+ }
53
63
  }
package/src/Logger.d.ts CHANGED
@@ -19,8 +19,8 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- import { ILogger, JsonObject } from '@imqueue/core';
23
- import { TransportOptions } from './TransportOptions';
22
+ import { type ILogger, type JsonObject } from './types.js';
23
+ import { type TransportOptions } from './TransportOptions.js';
24
24
  export interface AsyncLoggerOptions {
25
25
  transports: TransportOptions[];
26
26
  metadata: JsonObject;
package/src/Logger.js CHANGED
@@ -1,12 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Logger = void 0;
4
- const winston_1 = require("winston");
5
- const helpers_1 = require("./helpers");
1
+ /*!
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
21
+ */
22
+ import {} from './types.js';
23
+ import { createLogger, format, Logger as WinstonLogger, } from 'winston';
24
+ import { buildMessage, defaultMetadata, getTransport, transportsConfig, } from './helpers/index.js';
25
+ import {} from './TransportOptions.js';
6
26
  /**
7
27
  * Class Logger
8
28
  */
9
- class Logger {
29
+ export class Logger {
10
30
  /**
11
31
  * Asynchronous console async-logger
12
32
  *
@@ -28,8 +48,8 @@ class Logger {
28
48
  static getLoggerOptions(metadata) {
29
49
  return {
30
50
  exitOnError: false,
31
- format: winston_1.format.json(),
32
- defaultMeta: metadata || (0, helpers_1.defaultMetadata)(),
51
+ format: format.json(),
52
+ defaultMeta: metadata || defaultMetadata(),
33
53
  };
34
54
  }
35
55
  /**
@@ -46,9 +66,9 @@ class Logger {
46
66
  */
47
67
  constructor(options) {
48
68
  const opts = Logger.getLoggerOptions((options || {}).metadata);
49
- const config = (options || {}).transports || (0, helpers_1.transportsConfig)();
69
+ const config = (options || {}).transports || transportsConfig();
50
70
  if (config && config.length) {
51
- this.logger = (0, winston_1.createLogger)(opts);
71
+ this.logger = createLogger(opts);
52
72
  this.setupLogger(config);
53
73
  }
54
74
  }
@@ -61,7 +81,7 @@ class Logger {
61
81
  log(...args) {
62
82
  Logger.console.log(...args);
63
83
  if (this.logger) {
64
- this.logger.info((0, helpers_1.buildMessage)(args));
84
+ this.logger.info(buildMessage(args));
65
85
  }
66
86
  }
67
87
  /**
@@ -73,7 +93,7 @@ class Logger {
73
93
  info(...args) {
74
94
  Logger.console.info(...args);
75
95
  if (this.logger) {
76
- this.logger.info((0, helpers_1.buildMessage)(args));
96
+ this.logger.info(buildMessage(args));
77
97
  }
78
98
  }
79
99
  /**
@@ -85,7 +105,7 @@ class Logger {
85
105
  warn(...args) {
86
106
  Logger.console.warn(...args);
87
107
  if (this.logger) {
88
- this.logger.warn((0, helpers_1.buildMessage)(args));
108
+ this.logger.warn(buildMessage(args));
89
109
  }
90
110
  }
91
111
  /**
@@ -97,7 +117,7 @@ class Logger {
97
117
  error(...args) {
98
118
  Logger.console.error(...args);
99
119
  if (this.logger) {
100
- this.logger.error((0, helpers_1.buildMessage)(args));
120
+ this.logger.error(buildMessage(args));
101
121
  }
102
122
  }
103
123
  /**
@@ -114,7 +134,7 @@ class Logger {
114
134
  if (!options.enabled) {
115
135
  continue;
116
136
  }
117
- const transport = (0, helpers_1.getTransport)(options.type, options.options);
137
+ const transport = getTransport(options.type, options.options);
118
138
  // the constructor always creates the winston logger before
119
139
  // calling setupLogger(), the optional chaining only satisfies
120
140
  // strict property-initialization analysis
@@ -122,5 +142,4 @@ class Logger {
122
142
  }
123
143
  }
124
144
  }
125
- exports.Logger = Logger;
126
145
  //# sourceMappingURL=Logger.js.map
@@ -19,7 +19,7 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- import { LoggerOptions } from 'winston';
22
+ import { type LoggerOptions } from 'winston';
23
23
  /**
24
24
  * Interface IConfig
25
25
  */
@@ -1,3 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ /*!
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
21
+ */
22
+ import {} from 'winston';
3
23
  //# sourceMappingURL=TransportOptions.js.map
@@ -19,8 +19,8 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- import { JsonObject } from '@imqueue/core';
23
- import { TransportOptions } from '../TransportOptions';
22
+ import { type JsonObject } from '../types.js';
23
+ import { type TransportOptions } from '../TransportOptions.js';
24
24
  /**
25
25
  * Retrieve package name and version from package.json of running service
26
26
  *
@@ -1,10 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pkg = pkg;
4
- exports.transportsConfig = transportsConfig;
5
- exports.defaultMetadata = defaultMetadata;
6
- const path_1 = require("path");
7
- const fs_1 = require("fs");
1
+ /*!
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
21
+ */
22
+ import {} from '../types.js';
23
+ import { resolve } from 'path';
24
+ import { existsSync as exists, readFileSync } from 'fs';
25
+ import {} from '../TransportOptions.js';
8
26
  const RX_NAME = /%name/g;
9
27
  const RX_VERSION = /%version/g;
10
28
  /**
@@ -12,10 +30,10 @@ const RX_VERSION = /%version/g;
12
30
  *
13
31
  * @returns {name: string, value: string} - return package name and version
14
32
  */
15
- function pkg() {
16
- const pkgPath = (0, path_1.resolve)(process.cwd(), 'package.json');
17
- const { name, version } = (0, fs_1.existsSync)(pkgPath)
18
- ? require(pkgPath)
33
+ export function pkg() {
34
+ const pkgPath = resolve(process.cwd(), 'package.json');
35
+ const { name, version } = exists(pkgPath)
36
+ ? JSON.parse(readFileSync(pkgPath, 'utf8'))
19
37
  : { name: 'logger', version: '' };
20
38
  return { name, version };
21
39
  }
@@ -24,7 +42,7 @@ function pkg() {
24
42
  *
25
43
  * @returns {TransportOptions[]}
26
44
  */
27
- function transportsConfig() {
45
+ export function transportsConfig() {
28
46
  const { name, version } = pkg();
29
47
  try {
30
48
  return JSON.parse((process.env.LOGGER_TRANSPORTS || '[]')
@@ -40,7 +58,7 @@ function transportsConfig() {
40
58
  *
41
59
  * @returns {JsonObject}
42
60
  */
43
- function defaultMetadata() {
61
+ export function defaultMetadata() {
44
62
  const { name, version } = pkg();
45
63
  try {
46
64
  return JSON.parse((process.env.LOGGER_METADATA || '{}')
@@ -19,6 +19,6 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- export * from './env';
23
- export * from './message';
24
- export * from './transport';
22
+ export * from './env.js';
23
+ export * from './message.js';
24
+ export * from './transport.js';
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * I'm Queue Software Project
19
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -35,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
19
  * purchase a proprietary commercial license. Please contact us at
36
20
  * <support@imqueue.com> to get commercial licensing options.
37
21
  */
38
- __exportStar(require("./env"), exports);
39
- __exportStar(require("./message"), exports);
40
- __exportStar(require("./transport"), exports);
22
+ export * from './env.js';
23
+ export * from './message.js';
24
+ export * from './transport.js';
41
25
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildMessage = buildMessage;
4
1
  /*!
5
2
  * I'm Queue Software Project
6
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -22,14 +19,14 @@ exports.buildMessage = buildMessage;
22
19
  * purchase a proprietary commercial license. Please contact us at
23
20
  * <support@imqueue.com> to get commercial licensing options.
24
21
  */
25
- const util_1 = require("util");
22
+ import { format } from 'util';
26
23
  /**
27
24
  * Format message like console log
28
25
  *
29
26
  * @param {...*[]} args
30
27
  * @returns {string}
31
28
  */
32
- function buildMessage(args) {
33
- return (0, util_1.format)(args.shift(), ...args);
29
+ export function buildMessage(args) {
30
+ return format(args.shift(), ...args);
34
31
  }
35
32
  //# sourceMappingURL=message.js.map
@@ -1,5 +1,5 @@
1
- import * as Transport from 'winston-transport';
2
- import { FileTransportOptions, HttpTransportOptions } from 'winston/lib/winston/transports';
1
+ import type Transport from 'winston-transport';
2
+ import type { FileTransportOptions, HttpTransportOptions } from 'winston/lib/winston/transports/index.js';
3
3
  /**
4
4
  * Used for get configured transport by type
5
5
  *
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTransport = getTransport;
4
1
  /*!
5
2
  * I'm Queue Software Project
6
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -22,7 +19,7 @@ exports.getTransport = getTransport;
22
19
  * purchase a proprietary commercial license. Please contact us at
23
20
  * <support@imqueue.com> to get commercial licensing options.
24
21
  */
25
- const winston_1 = require("winston");
22
+ import { transports } from 'winston';
26
23
  /**
27
24
  * Used for get configured transport by type
28
25
  *
@@ -31,13 +28,13 @@ const winston_1 = require("winston");
31
28
  * options for configure transport
32
29
  * @returns {Transport}
33
30
  */
34
- function getTransport(type, options) {
31
+ export function getTransport(type, options) {
35
32
  let transportInstance = null;
36
33
  if (type === 'file') {
37
- transportInstance = new winston_1.transports.File(options);
34
+ transportInstance = new transports.File(options);
38
35
  }
39
36
  else if (type === 'http') {
40
- transportInstance = new winston_1.transports.Http(options);
37
+ transportInstance = new transports.Http(options);
41
38
  }
42
39
  return transportInstance;
43
40
  }
package/src/index.d.ts CHANGED
@@ -19,6 +19,7 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- export * from './helpers';
23
- export * from './TransportOptions';
24
- export * from './Logger';
22
+ export * from './types.js';
23
+ export * from './helpers/index.js';
24
+ export * from './TransportOptions.js';
25
+ export * from './Logger.js';
package/src/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * I'm Queue Software Project
19
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -35,7 +19,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
19
  * purchase a proprietary commercial license. Please contact us at
36
20
  * <support@imqueue.com> to get commercial licensing options.
37
21
  */
38
- __exportStar(require("./helpers"), exports);
39
- __exportStar(require("./TransportOptions"), exports);
40
- __exportStar(require("./Logger"), exports);
22
+ export * from './types.js';
23
+ export * from './helpers/index.js';
24
+ export * from './TransportOptions.js';
25
+ export * from './Logger.js';
41
26
  //# sourceMappingURL=index.js.map
package/src/types.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ /*!
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2026 imqueue.com <support@imqueue.com>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
21
+ */
22
+ /**
23
+ * Structural copies of the @imqueue/core types this package uses, kept
24
+ * local so the logger carries no runtime dependency on the queue library.
25
+ * The shapes match @imqueue/core exactly, so values typed here remain
26
+ * assignment-compatible with code written against the core interfaces.
27
+ */
28
+ /**
29
+ * Represents any JSON-serializable value
30
+ */
31
+ export type AnyJson = boolean | number | string | null | undefined | JsonArray | JsonObject;
32
+ /**
33
+ * Represents JSON serializable object
34
+ */
35
+ export interface JsonObject {
36
+ [key: string]: AnyJson;
37
+ }
38
+ /**
39
+ * Represents JSON-serializable array
40
+ */
41
+ export interface JsonArray extends Array<AnyJson> {
42
+ }
43
+ /**
44
+ * Logger interface
45
+ */
46
+ export interface ILogger {
47
+ /**
48
+ * Log level function
49
+ *
50
+ * @param {...unknown[]} args
51
+ */
52
+ log(...args: unknown[]): void;
53
+ /**
54
+ * Info level function
55
+ *
56
+ * @param {...unknown[]} args
57
+ */
58
+ info(...args: unknown[]): void;
59
+ /**
60
+ * Warning level function
61
+ *
62
+ * @param {...unknown[]} args
63
+ */
64
+ warn(...args: unknown[]): void;
65
+ /**
66
+ * Error level function
67
+ *
68
+ * @param {...unknown[]} args
69
+ */
70
+ error(...args: unknown[]): void;
71
+ }
package/src/types.js ADDED
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2026 imqueue.com <support@imqueue.com>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
21
+ */
22
+ export {};
23
+ //# sourceMappingURL=types.js.map