forked from hapijs/hapi-pino
/
index.test-d.ts
45 lines (41 loc) 路 1.19 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Request, Server } from '@hapi/hapi';
import pino from 'pino';
import * as HapiPino from '.';
import { expectType } from 'tsd';
const pinoLogger = pino();
const server = new Server();
const options: HapiPino.Options = {
timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`,
logQueryParams: false,
logPayload: false,
logRouteTags: false,
logRequestStart: false,
logRequestComplete: true,
stream: process.stdout,
prettyPrint: process.env.NODE_ENV !== 'PRODUCTION',
tags: {
trace: 'trace',
debug: 'debug',
info: 'info',
warn: 'warn',
error: 'error',
fatal: 'fatal',
},
allTags: 'info',
serializers: {
req: (req: any) => console.log(req),
},
getChildBindings: (req: Request) => ({
'x-request-id': req.headers['x-request-id'],
}),
instance: pinoLogger,
logEvents: false,
mergeHapiLogData: false,
ignorePaths: ['/testRoute'],
level: 'debug',
redact: ['test.property'],
ignoreTags: ['healthcheck'],
ignoreFunc: (options, request) => request.path.startsWith('/static'),
ignoredEventTags: [{ log: ['DEBUG', 'TEST'], request: ['DEBUG', 'TEST'] }],
};
expectType<Promise<void>>(server.register({ plugin: HapiPino, options }));