@globalart/nestjs-logger 2.4.2 → 2.5.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/dist/index.cjs +30 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +30 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="operators/index.d.ts" />
|
|
2
2
|
/// <reference path="testing/index.d.ts" />
|
|
3
|
-
import * as _nestjs_common0 from "@nestjs/common";
|
|
3
|
+
import * as _$_nestjs_common0 from "@nestjs/common";
|
|
4
4
|
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
6
|
|
|
@@ -513,11 +513,11 @@ interface LoggerModuleOptions {
|
|
|
513
513
|
exclude?: ExcludeOption[];
|
|
514
514
|
logRequests?: boolean;
|
|
515
515
|
}
|
|
516
|
-
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
516
|
+
declare const ConfigurableModuleClass: _$_nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
517
517
|
global: boolean;
|
|
518
518
|
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
519
519
|
global: boolean;
|
|
520
|
-
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
520
|
+
}>, ASYNC_OPTIONS_TYPE: _$_nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
521
521
|
global: boolean;
|
|
522
522
|
}>;
|
|
523
523
|
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
@@ -536,9 +536,9 @@ declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
|
536
536
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/decorators/index.d.ts
|
|
539
|
-
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
540
|
-
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
541
|
-
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
539
|
+
declare const LogContext: (context: string) => _$_nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
540
|
+
declare const LogMetadata: (metadata: Record<string, unknown>) => _$_nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
541
|
+
declare const ExcludeLogging: () => _$_nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
542
542
|
//#endregion
|
|
543
543
|
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
544
544
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="operators/index.d.ts" />
|
|
2
2
|
/// <reference path="testing/index.d.ts" />
|
|
3
|
-
import * as _nestjs_common0 from "@nestjs/common";
|
|
3
|
+
import * as _$_nestjs_common0 from "@nestjs/common";
|
|
4
4
|
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
6
|
|
|
@@ -513,11 +513,11 @@ interface LoggerModuleOptions {
|
|
|
513
513
|
exclude?: ExcludeOption[];
|
|
514
514
|
logRequests?: boolean;
|
|
515
515
|
}
|
|
516
|
-
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
516
|
+
declare const ConfigurableModuleClass: _$_nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
517
517
|
global: boolean;
|
|
518
518
|
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
519
519
|
global: boolean;
|
|
520
|
-
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
520
|
+
}>, ASYNC_OPTIONS_TYPE: _$_nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
521
521
|
global: boolean;
|
|
522
522
|
}>;
|
|
523
523
|
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
@@ -536,9 +536,9 @@ declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
|
536
536
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/decorators/index.d.ts
|
|
539
|
-
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
540
|
-
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
541
|
-
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
539
|
+
declare const LogContext: (context: string) => _$_nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
540
|
+
declare const LogMetadata: (metadata: Record<string, unknown>) => _$_nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
541
|
+
declare const ExcludeLogging: () => _$_nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
542
542
|
//#endregion
|
|
543
543
|
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
544
544
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -7074,7 +7074,7 @@ function getOpenTelemetryTraceIds() {
|
|
|
7074
7074
|
//#region src/core/trace-context.storage.ts
|
|
7075
7075
|
const traceContextStorage = new AsyncLocalStorage();
|
|
7076
7076
|
//#endregion
|
|
7077
|
-
//#region \0@oxc-project+runtime@0.
|
|
7077
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
|
|
7078
7078
|
function __decorate(decorators, target, key, desc) {
|
|
7079
7079
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7080
7080
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7108,7 +7108,7 @@ let TraceContextService = class TraceContextService {
|
|
|
7108
7108
|
};
|
|
7109
7109
|
TraceContextService = __decorate([Injectable()], TraceContextService);
|
|
7110
7110
|
//#endregion
|
|
7111
|
-
//#region \0@oxc-project+runtime@0.
|
|
7111
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/decorateMetadata.js
|
|
7112
7112
|
function __decorateMetadata(k, v) {
|
|
7113
7113
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7114
7114
|
}
|
|
@@ -7196,7 +7196,7 @@ LoggerService = __decorate([Injectable(), __decorateMetadata("design:paramtypes"
|
|
|
7196
7196
|
typeof (_ref$2 = typeof TraceContextService !== "undefined" && TraceContextService) === "function" ? _ref$2 : Object
|
|
7197
7197
|
])], LoggerService);
|
|
7198
7198
|
//#endregion
|
|
7199
|
-
//#region \0@oxc-project+runtime@0.
|
|
7199
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/decorateParam.js
|
|
7200
7200
|
function __decorateParam(paramIndex, decorator) {
|
|
7201
7201
|
return function(target, key) {
|
|
7202
7202
|
decorator(target, key, paramIndex);
|
|
@@ -7420,7 +7420,23 @@ let TextFormatter = class TextFormatter extends BaseFormatter {
|
|
|
7420
7420
|
return entry.trace ? this.addTrace(result, entry.trace) : result;
|
|
7421
7421
|
}
|
|
7422
7422
|
formatHttpRequest(entry) {
|
|
7423
|
-
|
|
7423
|
+
const parts = [];
|
|
7424
|
+
if (this.options.timestamp) parts.push(this.colorize(`[${new Date(entry.time).toISOString()}]`, "gray"));
|
|
7425
|
+
const level = entry.level >= 50 ? "error" : entry.level >= 40 ? "warn" : "info";
|
|
7426
|
+
parts.push(this.colorize(`[${level.toUpperCase()}]`, this.getColorForLevel(entry.level)));
|
|
7427
|
+
parts.push(this.colorize("[HTTP]", "cyan"));
|
|
7428
|
+
const { method, url, statusCode, responseTime } = {
|
|
7429
|
+
method: entry.req.method,
|
|
7430
|
+
url: entry.req.url,
|
|
7431
|
+
statusCode: entry.res.statusCode,
|
|
7432
|
+
responseTime: entry.responseTime
|
|
7433
|
+
};
|
|
7434
|
+
parts.push(this.colorize(`${method} ${url} ${statusCode} ${responseTime}ms`, "bright"));
|
|
7435
|
+
if (entry.traceId || entry.spanId) {
|
|
7436
|
+
const ids = [entry.traceId, entry.spanId].filter(Boolean).join("/");
|
|
7437
|
+
parts.push(this.colorize(`[${ids}]`, "magenta"));
|
|
7438
|
+
}
|
|
7439
|
+
return parts.join(" ");
|
|
7424
7440
|
}
|
|
7425
7441
|
buildLogParts(entry) {
|
|
7426
7442
|
const parts = [];
|
|
@@ -7599,14 +7615,15 @@ let ConsoleWriter = class ConsoleWriter {
|
|
|
7599
7615
|
ConsoleWriter = __decorate([Injectable()], ConsoleWriter);
|
|
7600
7616
|
//#endregion
|
|
7601
7617
|
//#region src/factories/dynamic-context-logger.factory.ts
|
|
7602
|
-
var _ref, _ref2, _ref3;
|
|
7618
|
+
var _ref, _ref2, _ref3, _ref4;
|
|
7603
7619
|
let DynamicContextLoggerFactory = class DynamicContextLoggerFactory {
|
|
7604
7620
|
loggerCache = /* @__PURE__ */ new Map();
|
|
7605
|
-
constructor(config, formatterFactory, writer, contextResolver) {
|
|
7621
|
+
constructor(config, formatterFactory, writer, contextResolver, traceContextService) {
|
|
7606
7622
|
this.config = config;
|
|
7607
7623
|
this.formatterFactory = formatterFactory;
|
|
7608
7624
|
this.writer = writer;
|
|
7609
7625
|
this.contextResolver = contextResolver;
|
|
7626
|
+
this.traceContextService = traceContextService;
|
|
7610
7627
|
}
|
|
7611
7628
|
createLogger(context) {
|
|
7612
7629
|
if (this.loggerCache.has(context)) return this.loggerCache.get(context);
|
|
@@ -7615,7 +7632,7 @@ let DynamicContextLoggerFactory = class DynamicContextLoggerFactory {
|
|
|
7615
7632
|
timestamp: this.config.timestamp,
|
|
7616
7633
|
context: this.config.context
|
|
7617
7634
|
});
|
|
7618
|
-
const logger = new LoggerService(this.config, formatter, this.writer, this.contextResolver);
|
|
7635
|
+
const logger = new LoggerService(this.config, formatter, this.writer, this.contextResolver, this.traceContextService);
|
|
7619
7636
|
logger.setContext(context);
|
|
7620
7637
|
this.loggerCache.set(context, logger);
|
|
7621
7638
|
return logger;
|
|
@@ -7628,7 +7645,8 @@ DynamicContextLoggerFactory = __decorate([
|
|
|
7628
7645
|
Object,
|
|
7629
7646
|
typeof (_ref = typeof FormatterFactory !== "undefined" && FormatterFactory) === "function" ? _ref : Object,
|
|
7630
7647
|
typeof (_ref2 = typeof ConsoleWriter !== "undefined" && ConsoleWriter) === "function" ? _ref2 : Object,
|
|
7631
|
-
typeof (_ref3 = typeof ContextResolver !== "undefined" && ContextResolver) === "function" ? _ref3 : Object
|
|
7648
|
+
typeof (_ref3 = typeof ContextResolver !== "undefined" && ContextResolver) === "function" ? _ref3 : Object,
|
|
7649
|
+
typeof (_ref4 = typeof TraceContextService !== "undefined" && TraceContextService) === "function" ? _ref4 : Object
|
|
7632
7650
|
])
|
|
7633
7651
|
], DynamicContextLoggerFactory);
|
|
7634
7652
|
//#endregion
|
|
@@ -7769,18 +7787,19 @@ let LoggerModule = class LoggerModule extends ConfigurableModuleClass {
|
|
|
7769
7787
|
},
|
|
7770
7788
|
{
|
|
7771
7789
|
provide: LOGGER_SERVICE_TOKEN,
|
|
7772
|
-
useFactory: (config, formatterFactory, writer, contextResolver) => {
|
|
7790
|
+
useFactory: (config, formatterFactory, writer, contextResolver, traceContextService) => {
|
|
7773
7791
|
return new LoggerService(config, formatterFactory.create(config.format, {
|
|
7774
7792
|
colors: config.colors,
|
|
7775
7793
|
timestamp: config.timestamp,
|
|
7776
7794
|
context: config.context
|
|
7777
|
-
}), writer, contextResolver);
|
|
7795
|
+
}), writer, contextResolver, traceContextService);
|
|
7778
7796
|
},
|
|
7779
7797
|
inject: [
|
|
7780
7798
|
LOGGER_CONFIG_TOKEN,
|
|
7781
7799
|
FormatterFactory,
|
|
7782
7800
|
ConsoleWriter,
|
|
7783
|
-
ContextResolver
|
|
7801
|
+
ContextResolver,
|
|
7802
|
+
TraceContextService
|
|
7784
7803
|
]
|
|
7785
7804
|
},
|
|
7786
7805
|
{
|