-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add logger middleware and logger class * update logger level setting
- Loading branch information
1 parent
bbcf1a8
commit c978f63
Showing
3 changed files
with
44 additions
and
1 deletion.
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
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,41 @@ | ||
import {Shape, Member} from './protocol' | ||
|
||
/** | ||
* A list of logger's log level. These levels are sorted in | ||
* order of increasing severity. Each log level includes itself and all | ||
* the levels behind itself. | ||
* | ||
* @example new Logger({logLevel: 'warn'}) will print all the warn and error | ||
* message. | ||
*/ | ||
export type LogLevel = 'all' | 'log' | 'info' | 'warn' | 'error' | 'off' | ||
|
||
/** | ||
* An object consumed by Logger constructor to initiate a logger object. | ||
*/ | ||
export interface LoggerOptions { | ||
logger?: Logger; | ||
logLevel?: LogLevel; | ||
} | ||
|
||
/** | ||
* Represents a logger object that is available in HandlerExecutionContext | ||
* throughout the middleware stack. | ||
*/ | ||
export interface Logger { | ||
log(content: string): void; | ||
info(content: string): void; | ||
warn(content: string): void; | ||
error(content: string): void; | ||
} | ||
|
||
/** | ||
* A function that removes the sensitive information from input parameters | ||
* and output objects being logged. Meanwhile this function will output | ||
* stringified object | ||
* | ||
* This function is mainly used in logging middleware. | ||
*/ | ||
export interface SensitiveDataScrubber { | ||
(input: any, shape: Member): string | ||
} |
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