Skip to content

Commit e5a697d

Browse files
committed
feat: add pino logger options
1 parent e5b23db commit e5a697d

8 files changed

Lines changed: 1163 additions & 16 deletions

File tree

MODULES.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Modules
2+
3+
All modules are importable via subpath exports from `@dailydotdev/node-common`.
4+
5+
## logger
6+
7+
**Import:** `@dailydotdev/node-common/logger`
8+
9+
Pino logger configuration that adapts to the current environment.
10+
11+
- **Development:** uses `pino-pretty` for human-readable output.
12+
- **Production (GCP):** uses `@google-cloud/pino-logging-gcp-config` when `OTEL_LOGGER_FORMAT=gcp`.
13+
- **Production (OTel):** uses OpenTelemetry-compatible format when `OTEL_LOGGER_FORMAT=otel`.
14+
15+
| Export | Type | Description |
16+
| ------------------ | --------------- | -------------------------------------------------------- |
17+
| `pinoLoggerConfig` | `LoggerOptions` | Pre-built Pino configuration for the current environment |
18+
19+
## utils
20+
21+
**Import:** `@dailydotdev/node-common/utils`
22+
23+
General utility functions.
24+
25+
| Export | Type | Description |
26+
| ------- | ---------------------------------- | ----------------------------------------- |
27+
| `sleep` | `(delay: number) => Promise<void>` | Pauses execution for a specified duration |
28+
29+
## utils/env
30+
31+
**Import:** `@dailydotdev/node-common/utils/env`
32+
33+
Environment detection helpers.
34+
35+
| Export | Type | Description |
36+
| --------------- | --------- | --------------------------------------- |
37+
| `isDevelopment` | `boolean` | `true` when `NODE_ENV` is `development` |
38+
| `isProduction` | `boolean` | `true` when `NODE_ENV` is `production` |
39+
| `isTest` | `boolean` | `true` when `NODE_ENV` is `test` |

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ await sleep(1000); // pause for 1 second
2020

2121
## Modules
2222

23-
| Module | Import Path | Description |
24-
| ------ | --------------------------------- | --------------------- |
25-
| utils | `@dailydotdev/node-common/utils` | General utilities |
26-
| logger | `@dailydotdev/node-common/logger` | Logging (coming soon) |
23+
See [MODULES.md](./MODULES.md) for the full list of available modules.
2724

2825
## Development
2926

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22
"name": "@dailydotdev/node-common",
33
"version": "0.0.1",
44
"description": "Shared packages for daily.dev Node.js projects",
5+
"license": "BSD-3-Clause",
6+
"contributors": [
7+
"omBratteng"
8+
],
59
"type": "module",
610
"exports": {
711
"./*": {
8-
"typescript": "./src/*/index.ts",
12+
"typescript": "./src/*/*.ts",
913
"import": {
10-
"types": "./dist/*/index.d.ts",
11-
"default": "./dist/*/index.js"
14+
"types": "./dist/*/*.d.ts",
15+
"default": "./dist/*/*.js"
1216
},
1317
"require": {
14-
"types": "./dist/*/index.d.cts",
15-
"default": "./dist/*/index.cjs"
18+
"types": "./dist/*/*.d.cts",
19+
"default": "./dist/*/*.cjs"
1620
}
1721
}
1822
},
@@ -28,11 +32,10 @@
2832
"lint:fix": "eslint . --fix",
2933
"format": "prettier --write ."
3034
},
31-
"keywords": [],
32-
"contributors": [
33-
"omBratteng"
34-
],
35-
"license": "BSD-3-Clause",
35+
"dependencies": {
36+
"@google-cloud/pino-logging-gcp-config": "^1.3.1",
37+
"pino": "^10.3.1"
38+
},
3639
"devDependencies": {
3740
"@eslint/js": "^9.39.2",
3841
"@types/node": "22.x",

0 commit comments

Comments
 (0)