express-winston: relax types on meta object (#25036)

* express-winston: relax types on meta object

* express-winston: change meta object type to
This commit is contained in:
Dylan Scott
2018-04-17 08:37:05 -07:00
committed by Ryan Cavanaugh
parent 2b5e8a5dd3
commit d12aef03df
2 changed files with 5 additions and 9 deletions
@@ -6,7 +6,7 @@ const app = express();
// Logger with all options
app.use(expressWinston.logger({
baseMeta: { foo: 'foo' },
baseMeta: { foo: 'foo', nested: { bar: 'baz' } },
bodyBlacklist: ['foo'],
bodyWhitelist: ['bar'],
colorize: true,
@@ -47,7 +47,7 @@ app.use(expressWinston.logger({
// Error Logger with all options
app.use(expressWinston.errorLogger({
baseMeta: { foo: 'foo' },
baseMeta: { foo: 'foo', nested: { bar: 'baz' } },
dynamicMeta: (req, res, err) => ({ foo: 'bar' }),
level: (req, res) => 'level',
metaField: 'metaField',
+3 -7
View File
@@ -7,18 +7,14 @@
import { ErrorRequestHandler, Handler, Request, Response } from 'express';
import { TransportInstance, Winston } from 'winston';
export interface MetaObject {
[field: string]: string;
}
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => MetaObject | undefined;
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => object;
export type DynamicLevelFunction = (req: Request, res: Response, err: Error) => string;
export type RequestFilter = (req: Request, propName: string) => boolean;
export type ResponseFilter = (res: Response, propName: string) => boolean;
export type RouteFilter = (req: Request, res: Response) => boolean;
export interface BaseLoggerOptions {
baseMeta?: MetaObject;
baseMeta?: object;
bodyBlacklist?: string[];
bodyWhitelist?: string[];
colorize?: boolean;
@@ -55,7 +51,7 @@ export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinst
export function logger(options: LoggerOptions): Handler;
export interface BaseErrorLoggerOptions {
baseMeta?: MetaObject;
baseMeta?: object;
dynamicMeta?: DynamicMetaFunction;
level?: string | DynamicLevelFunction;
metaField?: string;