Skip to content
Merged

V3 #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
import { Logger } from './src';
import { Logger } from './src/index.js';

export * from './src';
export * from './src/index.js';

// noinspection JSUnusedGlobalSymbols
export default new Logger();
107 changes: 5 additions & 102 deletions package-lock.json

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

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imqueue/async-logger",
"version": "3.0.1",
"version": "3.1.0",
"description": "Configurable async logger over winston for @imqueue services",
"keywords": [
"logger",
Expand Down Expand Up @@ -38,7 +38,6 @@
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
"license": "GPL-3.0-only",
"dependencies": {
"@imqueue/core": "^3.1.1",
"winston": "^3.19.0",
"winston-transport": "^4.9.0"
},
Expand All @@ -49,5 +48,16 @@
"typescript": "^7.0.2"
},
"main": "index.js",
"types": "index.d.ts"
"types": "index.d.ts",
"type": "module",
"engines": {
"node": ">=22.12.0"
},
"exports": {
".": {
"types": "./index.d.ts",
"default": "./index.js"
},
"./package.json": "./package.json"
}
}
8 changes: 4 additions & 4 deletions src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
import { ILogger, JsonObject } from '@imqueue/core';
import { type ILogger, type JsonObject } from './types.js';
import {
createLogger,
format,
Logger as WinstonLogger,
LoggerOptions,
type LoggerOptions,
} from 'winston';
import {
buildMessage,
defaultMetadata,
getTransport,
transportsConfig,
} from './helpers';
import { TransportOptions } from './TransportOptions';
} from './helpers/index.js';
import { type TransportOptions } from './TransportOptions.js';

export interface AsyncLoggerOptions {
transports: TransportOptions[];
Expand Down
2 changes: 1 addition & 1 deletion src/TransportOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
import { LoggerOptions } from 'winston';
import { type LoggerOptions } from 'winston';

/**
* Interface IConfig
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
import { JsonObject } from '@imqueue/core';
import { type JsonObject } from '../types.js';
import { resolve } from 'path';
import { existsSync as exists } from 'fs';
import { TransportOptions } from '../TransportOptions';
import { existsSync as exists, readFileSync } from 'fs';
import { type TransportOptions } from '../TransportOptions.js';

const RX_NAME = /%name/g;
const RX_VERSION = /%version/g;
Expand All @@ -35,7 +35,7 @@ const RX_VERSION = /%version/g;
export function pkg(): { name: string; version: string } {
const pkgPath = resolve(process.cwd(), 'package.json');
const { name, version } = exists(pkgPath)
? require(pkgPath)
? JSON.parse(readFileSync(pkgPath, 'utf8'))
: { name: 'logger', version: '' };

return { name, version };
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
export * from './env';
export * from './message';
export * from './transport';
export * from './env.js';
export * from './message.js';
export * from './transport.js';
6 changes: 3 additions & 3 deletions src/helpers/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* <support@imqueue.com> to get commercial licensing options.
*/
import { transports } from 'winston';
import * as Transport from 'winston-transport';
import {
import type Transport from 'winston-transport';
import type {
FileTransportOptions,
HttpTransportOptions,
} from 'winston/lib/winston/transports';
} from 'winston/lib/winston/transports/index.js';

/**
* Used for get configured transport by type
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/
export * from './helpers';
export * from './TransportOptions';
export * from './Logger';
export * from './types.js';
export * from './helpers/index.js';
export * from './TransportOptions.js';
export * from './Logger.js';
85 changes: 85 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*!
* I'm Queue Software Project
* Copyright (C) 2026 imqueue.com <support@imqueue.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* If you want to use this code in a closed source (commercial) project, you can
* purchase a proprietary commercial license. Please contact us at
* <support@imqueue.com> to get commercial licensing options.
*/

/**
* Structural copies of the @imqueue/core types this package uses, kept
* local so the logger carries no runtime dependency on the queue library.
* The shapes match @imqueue/core exactly, so values typed here remain
* assignment-compatible with code written against the core interfaces.
*/

/**
* Represents any JSON-serializable value
*/
export type AnyJson =
| boolean
| number
| string
| null
| undefined
| JsonArray
| JsonObject;

/**
* Represents JSON serializable object
*/
export interface JsonObject {
[key: string]: AnyJson;
}

/**
* Represents JSON-serializable array
*/
export interface JsonArray extends Array<AnyJson> {}

/**
* Logger interface
*/
export interface ILogger {
/**
* Log level function
*
* @param {...unknown[]} args
*/
log(...args: unknown[]): void;

/**
* Info level function
*
* @param {...unknown[]} args
*/
info(...args: unknown[]): void;

/**
* Warning level function
*
* @param {...unknown[]} args
*/
warn(...args: unknown[]): void;

/**
* Error level function
*
* @param {...unknown[]} args
*/
error(...args: unknown[]): void;
}
Loading
Loading