-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from yinzara/metadata-name
Enhance "metaField" and add "requestField and "responseField" options
- Loading branch information
Showing
10 changed files
with
794 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
chaset = utf-8 | ||
trim_trailing_whitespace = true | ||
ij_javascript_use_semicolon_after_statement = true | ||
ij_javascript_space_before_function_left_parenth = true | ||
ij_javascript_space_before_method_left_brace = true | ||
ij_javascript_space_before_method_parentheses = false | ||
|
||
[test/*.js] | ||
indent_size = 2 | ||
|
||
[package.json] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Ross Brandes <[email protected]> | |
Kévin Maschtaler (https://www.kmaschta.me) | ||
Matthew Blasius <[email protected]> (https://expel.io) | ||
Maxime David <[email protected]> | ||
Matt Morrissette <[email protected]> (https://github.com/yinzara) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Type definitions for express-winston 4.0 | ||
// Project: https://github.com/bithavoc/express-winston#readme | ||
// Definitions by: Alex Brick <https://github.com/bricka> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 | ||
|
||
import { ErrorRequestHandler, Handler, Request, Response } from 'express'; | ||
import { Format } from 'logform'; | ||
import * as winston from 'winston'; | ||
import * as Transport from 'winston-transport'; | ||
|
||
export interface FilterRequest extends Request { | ||
[other: string]: any; | ||
} | ||
|
||
export interface FilterResponse extends Response { | ||
[other: string]: any; | ||
} | ||
|
||
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => object; | ||
export type DynamicLevelFunction = (req: Request, res: Response, err: Error) => string; | ||
export type RequestFilter = (req: FilterRequest, propName: string) => any; | ||
export type ResponseFilter = (res: FilterResponse, propName: string) => any; | ||
export type RouteFilter = (req: Request, res: Response) => boolean; | ||
export type MessageTemplate = string | ((req: Request, res: Response) => string); | ||
|
||
export interface BaseLoggerOptions { | ||
baseMeta?: object; | ||
bodyBlacklist?: string[]; | ||
bodyWhitelist?: string[]; | ||
colorize?: boolean; | ||
dynamicMeta?: DynamicMetaFunction; | ||
expressFormat?: boolean; | ||
format?: Format; | ||
ignoreRoute?: RouteFilter; | ||
ignoredRoutes?: string[]; | ||
level?: string | DynamicLevelFunction; | ||
meta?: boolean; | ||
metaField?: string; | ||
requestField?: string; | ||
responseField?: string; | ||
msg?: MessageTemplate; | ||
requestFilter?: RequestFilter; | ||
requestWhitelist?: string[]; | ||
responseFilter?: ResponseFilter; | ||
responseWhitelist?: string[]; | ||
skip?: RouteFilter; | ||
statusLevels?: { | ||
error?: string; | ||
success?: string; | ||
warn?: string; | ||
}; | ||
} | ||
|
||
export interface LoggerOptionsWithTransports extends BaseLoggerOptions { | ||
transports: Transport[]; | ||
} | ||
|
||
export interface LoggerOptionsWithWinstonInstance extends BaseLoggerOptions { | ||
winstonInstance: winston.Logger; | ||
} | ||
|
||
export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinstonInstance; | ||
|
||
export function logger(options: LoggerOptions): Handler; | ||
|
||
export interface BaseErrorLoggerOptions { | ||
baseMeta?: object; | ||
dynamicMeta?: DynamicMetaFunction; | ||
format?: Format; | ||
level?: string | DynamicLevelFunction; | ||
meta?: boolean; | ||
metaField?: string; | ||
requestField?: string; | ||
msg?: MessageTemplate; | ||
requestFilter?: RequestFilter; | ||
requestWhitelist?: string[]; | ||
} | ||
|
||
export interface ErrorLoggerOptionsWithTransports extends BaseErrorLoggerOptions { | ||
transports: Transport[]; | ||
} | ||
|
||
export interface ErrorLoggerOptionsWithWinstonInstance extends BaseErrorLoggerOptions { | ||
winstonInstance: winston.Logger; | ||
} | ||
|
||
export type ErrorLoggerOptions = ErrorLoggerOptionsWithTransports | ErrorLoggerOptionsWithWinstonInstance; | ||
|
||
export function errorLogger(options: ErrorLoggerOptions): ErrorRequestHandler; | ||
|
||
export let requestWhitelist: string[]; | ||
|
||
export let bodyWhitelist: string[]; | ||
|
||
export let bodyBlacklist: string[]; | ||
|
||
export let responseWhitelist: string[]; | ||
|
||
export let ignoredRoutes: string[]; | ||
|
||
export let defaultRequestFilter: RequestFilter; | ||
|
||
export let defaultResponseFilter: ResponseFilter; | ||
|
||
export function defaultSkip(): boolean; | ||
|
||
export interface ExpressWinstonRequest extends Request { | ||
_routeWhitelists: { | ||
body: string[]; | ||
req: string[]; | ||
res: string[]; | ||
}; | ||
} |
Oops, something went wrong.