[express-bunyan-logger] Update Options.

The options are passed through to bunyan.createLogger so all those
options need to be valid. A `Partial` is used because the only required
option by `createLogger` is `name` but the middleware provides a
default.
This commit is contained in:
Matt R. Wilson
2019-03-05 20:35:03 -07:00
parent 0337cd94b1
commit 4aadffd8bc
2 changed files with 11 additions and 2 deletions

View File

@@ -22,3 +22,12 @@ const logger = Bunyan.createLogger({
const middleware5 = expressBunyan({
logger
});
expressBunyan({
format: () => "some format",
genReqId: req => req.header("foo") || "other",
name: "foo_app",
parseUA: false,
serializers: Bunyan.stdSerializers,
streams: [{ level: 'info', stream: process.stdout }]
});

View File

@@ -1,6 +1,7 @@
// Type definitions for express-bunyan-logger 1.3
// Project: https://github.com/villadora/express-bunyan-logger
// Definitions by: Shrey Jain <https://github.com/shreyjain1994>
// Matt R. Wilson <https://github.com/mastermatt>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -17,7 +18,7 @@ declare namespace Factory {
type RequestIdGenFunction = (req: express.Request) => string;
type LevelFunction = (status: number, err: Error | null, meta: any) => string;
interface Options {
interface Options extends Partial<Bunyan.LoggerOptions> {
logger?: Bunyan;
format?: string | FormatFunction;
parseUA?: boolean;
@@ -26,7 +27,6 @@ declare namespace Factory {
excludes?: string[];
obfuscate?: string[];
obfuscatePlaceholder?: string;
serializers?: { [field: string]: Bunyan.Serializer };
immediate?: boolean;
genReqId?: RequestIdGenFunction;
}