Skip to content

Commit f8552a5

Browse files
authored
feat(winston): add TS types (#88)
Based on #82 which added types for Pino.
1 parent 9171ce5 commit f8552a5

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

loggers/winston/index.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { Format } from "winston";
2+
3+
interface Config {
4+
/**
5+
* Whether to convert a logged `err` field to ECS error fields.
6+
* Default true.
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+
export = (opts?: Config) => Format

loggers/winston/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.1.0",
44
"description": "A formatter for the winston logger compatible with Elastic Common Schema.",
55
"main": "index.js",
6+
"types": "index.d.ts",
67
"files": [
78
"index.js"
89
],

0 commit comments

Comments
 (0)