mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
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:
committed by
Ryan Cavanaugh
parent
2b5e8a5dd3
commit
d12aef03df
@@ -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',
|
||||
|
||||
Vendored
+3
-7
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user