@voiceflow/logger
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,5 +1,7 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node/http" /> | ||
import type { IncomingMessage } from 'node:http'; | ||
import { Options } from 'pino-http'; | ||
import { LoggerOptions } from './logger-options.interface'; | ||
export declare const createHTTPConfig: ({ format, level }: LoggerOptions) => Options; | ||
export declare const createHTTPLogger: (options: LoggerOptions) => import("pino-http").HttpLogger<import("http").IncomingMessage, import("http").ServerResponse, never>; | ||
export declare const createHTTPLogger: (options: LoggerOptions) => import("pino-http").HttpLogger<IncomingMessage, import("http").ServerResponse, never>; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.createHTTPLogger = exports.createHTTPConfig = void 0; | ||
/* eslint-disable sonarjs/no-nested-template-literals */ | ||
const colorette_1 = require("colorette"); | ||
@@ -25,5 +24,8 @@ const pino_http_1 = __importDefault(require("pino-http")); | ||
}, wrapSerializers: true }, (0, ts_pattern_1.match)(format) | ||
.with(log_format_enum_1.LogFormat.INLINE, () => (Object.assign({ customSuccessMessage: (req, res) => `${(0, utils_1.getColorizer)(res)(`(${res.statusCode})`)} ${(0, colorette_1.white)(`${req.method} ${req.url}`)} ${(0, colorette_1.gray)(`(${req.socket.remoteAddress}:${req.socket.remotePort})`)}`, customErrorMessage: (req, res) => { | ||
.with(log_format_enum_1.LogFormat.INLINE, () => (Object.assign({ customSuccessMessage: (req, res) => { | ||
var _a; | ||
return `${(0, utils_1.getColorizer)(res)(`(${res.statusCode})`)} ${(0, colorette_1.white)(`${req.method} ${req.url} -`)} ${(0, colorette_1.gray)(`(${req.socket.remoteAddress}:${req.socket.remotePort})`)} ${(_a = res.err) === null || _a === void 0 ? void 0 : _a.message}`; | ||
return `${(0, utils_1.getColorizer)(res)(`(${res.statusCode})`)} ${(0, colorette_1.white)(`${req.method} ${(_a = req.originalUrl) !== null && _a !== void 0 ? _a : req.url}`)} ${(0, colorette_1.gray)(`(${req.socket.remoteAddress}:${req.socket.remotePort})`)}`; | ||
}, customErrorMessage: (req, res) => { | ||
var _a, _b; | ||
return `${(0, utils_1.getColorizer)(res)(`(${res.statusCode})`)} ${(0, colorette_1.white)(`${req.method} ${(_a = req.originalUrl) !== null && _a !== void 0 ? _a : req.url}`)} ${(0, colorette_1.gray)(`(${req.socket.remoteAddress}:${req.socket.remotePort})`)} - ${(_b = res.err) === null || _b === void 0 ? void 0 : _b.message}`; | ||
} }, (0, inline_logger_1.createInlineConfig)(level)))) | ||
@@ -30,0 +32,0 @@ .with(log_format_enum_1.LogFormat.DETAILED, () => (0, detailed_logger_1.createDetailedConfig)(level)) |
@@ -1,24 +0,2 @@ | ||
import { SerializedError, SerializedRequest, SerializedResponse } from 'pino'; | ||
export declare const MaximalSerializer: { | ||
req: (req: SerializedRequest) => { | ||
id: string | undefined; | ||
method: string; | ||
url: string; | ||
query: Record<string, string>; | ||
params: Record<string, string>; | ||
headers: { | ||
[k: string]: string; | ||
}; | ||
remoteAddress: string; | ||
remotePort: number; | ||
}; | ||
res: (res: SerializedResponse) => { | ||
statusCode: number; | ||
headers: Record<string, string>; | ||
}; | ||
err: (err: SerializedError) => { | ||
type: string; | ||
message: string; | ||
stack: string; | ||
}; | ||
}; | ||
import type { Serializer } from './serializer.interface'; | ||
export declare const MaximalSerializer: Serializer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MaximalSerializer = void 0; | ||
const minimal_1 = require("./minimal"); | ||
exports.MaximalSerializer = { | ||
req: (req) => ({ | ||
id: req.id, | ||
method: req.method, | ||
url: req.url, | ||
query: req.query, | ||
params: req.params, | ||
headers: Object.fromEntries(Object.entries(req.headers).filter(([key]) => key === 'authorization')), | ||
remoteAddress: req.remoteAddress, | ||
remotePort: req.remotePort, | ||
}), | ||
res: (res) => ({ | ||
statusCode: res.statusCode, | ||
headers: res.headers, | ||
}), | ||
err: (err) => ({ | ||
type: err.type, | ||
message: err.message, | ||
stack: err.stack, | ||
}), | ||
req: (req) => (Object.assign(Object.assign({}, minimal_1.MinimalSerializer.req(req)), { headers: Object.fromEntries(Object.entries(req.headers).filter(([key]) => key === 'authorization')) })), | ||
res: (res) => (Object.assign(Object.assign({}, minimal_1.MinimalSerializer.res(res)), { headers: res.headers })), | ||
err: (err) => minimal_1.MinimalSerializer.err(err), | ||
}; | ||
//# sourceMappingURL=maximal.js.map |
@@ -1,19 +0,2 @@ | ||
import { SerializedError, SerializedRequest, SerializedResponse } from 'pino'; | ||
export declare const MinimalSerializer: { | ||
req: (req: SerializedRequest) => { | ||
method: string; | ||
url: string; | ||
query: Record<string, string>; | ||
params: Record<string, string>; | ||
remoteAddress: string; | ||
remotePort: number; | ||
}; | ||
res: (res: SerializedResponse) => { | ||
statusCode: number; | ||
}; | ||
err: (err: SerializedError) => { | ||
type: string; | ||
message: string; | ||
stack: string; | ||
}; | ||
}; | ||
import type { Serializer } from './serializer.interface'; | ||
export declare const MinimalSerializer: Serializer; |
@@ -5,10 +5,13 @@ "use strict"; | ||
exports.MinimalSerializer = { | ||
req: (req) => ({ | ||
method: req.method, | ||
url: req.url, | ||
query: req.query, | ||
params: req.params, | ||
remoteAddress: req.remoteAddress, | ||
remotePort: req.remotePort, | ||
}), | ||
req: (req) => { | ||
var _a; | ||
return ({ | ||
method: req.method, | ||
url: (_a = req.raw.originalUrl) !== null && _a !== void 0 ? _a : req.url, | ||
query: req.query, | ||
params: req.params, | ||
remoteAddress: req.remoteAddress, | ||
remotePort: req.remotePort, | ||
}); | ||
}, | ||
res: (res) => ({ | ||
@@ -15,0 +18,0 @@ statusCode: res.statusCode, |
{ | ||
"name": "@voiceflow/logger", | ||
"description": "Common logger for Voiceflow backend microservices", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": "Frank Gu <frank@voiceflow.com>", | ||
@@ -47,2 +47,3 @@ "bugs": { | ||
"prettier": "2.7.1", | ||
"rimraf": "5.0.0", | ||
"ts-mocha": "10.0.0", | ||
@@ -52,2 +53,5 @@ "tsc-alias": "1.7.0", | ||
}, | ||
"engines": { | ||
"node": "20" | ||
}, | ||
"files": [ | ||
@@ -62,2 +66,3 @@ "build/" | ||
"main": "build/main.js", | ||
"packageManager": "yarn@3.2.1", | ||
"prettier": "@voiceflow/prettier-config", | ||
@@ -67,3 +72,3 @@ "repository": "git@github.com:voiceflow/logger.git", | ||
"build": "yarn clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", | ||
"clean": "rimraf build", | ||
"clean": "yarn rimraf build", | ||
"commit": "cz", | ||
@@ -82,3 +87,7 @@ "eslint-output": "eslint-output", | ||
}, | ||
"types": "build/main.d.ts" | ||
"types": "build/main.d.ts", | ||
"volta": { | ||
"node": "20.10.0", | ||
"yarn": "3.2.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41
23938
28
281