Skip to content

Commit 9171ce5

Browse files
authored
Add TypeScript types for Pino logger (#82)
1 parent 0c6094f commit 9171ce5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

loggers/pino/index.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { LoggerOptions } from "pino";
2+
3+
interface Config {
4+
/**
5+
* Whether to convert a logged `err` field to ECS error fields.
6+
* Default true, to match Pino's default of having an `err` serializer.
7+
*/
8+
convertErr?: boolean;
9+
/**
10+
* Whether to convert logged `req` and `res` HTTP request and response fields
11+
* to ECS HTTP, User agent, and URL fields. Default false.
12+
*/
13+
convertReqRes?: boolean;
14+
/**
15+
* Whether to automatically integrate with
16+
* Elastic APM (https://github.com/elastic/apm-agent-nodejs). If a started
17+
* APM agent is detected, then log records will include the following
18+
* fields:
19+
*
20+
* - "service.name" - the configured serviceName in the agent
21+
* - "event.dataset" - set to "$serviceName.log" for correlation in Kibana
22+
* - "trace.id", "transaction.id", and "span.id" - if there is a current
23+
* active trace when the log call is made
24+
*
25+
* Default true.
26+
*/
27+
apmIntegration?: boolean;
28+
}
29+
30+
declare function createEcsPinoOptions(config?: Config): LoggerOptions;
31+
32+
export = createEcsPinoOptions;

loggers/pino/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"files": [
77
"index.js"
88
],
9+
"types": "index.d.ts",
910
"repository": {
1011
"type": "git",
1112
"url": "git+https://github.com/elastic/ecs-logging-nodejs.git"
@@ -37,6 +38,7 @@
3738
"@elastic/ecs-helpers": "^1.1.0"
3839
},
3940
"devDependencies": {
41+
"@types/pino": "^6.3.9",
4042
"ajv": "^7.0.3",
4143
"ajv-formats": "^1.5.1",
4244
"elastic-apm-node": "^3.14.0",

0 commit comments

Comments
 (0)