Skip to content

Commit 5a9fae5

Browse files
committed
feat: update logger configuration
1 parent 2e1fc05 commit 5a9fae5

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

.github/workflows/npm-publish.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@ jobs:
1616
with:
1717
node-version: 20
1818
registry-url: https://registry.npmjs.org/
19-
- run: npm ci
20-
- run: npm test
21-
- run: npm run build
22-
- run: npm publish
19+
cache: "npm"
20+
- name: Install dependencies
21+
run: npm ci
22+
- name: Run tests
23+
run: npm test
24+
- name: Build package
25+
run: npm run build
26+
- name: Check package version matches release
27+
run: |
28+
PKG_VERSION=$(node -p "require('./package.json').version")
29+
GITHUB_REF_VERSION=${GITHUB_REF#refs/tags/v}
30+
if [ "$PKG_VERSION" != "$GITHUB_REF_VERSION" ]; then
31+
echo "::error::Package version ($PKG_VERSION) does not match release tag ($GITHUB_REF_VERSION)"
32+
exit 1
33+
fi
34+
- name: Publish to NPM
35+
run: npm publish --provenance --access public
2336
env:
2437
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"algorithm"
1313
],
1414
"scripts": {
15-
"test": "vitest run",
15+
"test": "vitest run | pino-pretty",
1616
"test:watch": "vitest watch",
1717
"build": "tsc && chmod u+x build/index.js",
1818
"start": "node build/index.js",

src/utils/logger.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
import { pino } from "pino";
22

3-
const prodConfig = {
3+
const logger = pino({
44
level: "info",
55
formatters: {
66
level: (label: string) => ({ level: label.toUpperCase() })
77
},
88
timestamp: () => `,"timestamp":"${new Date().toISOString()}"`,
99
messageKey: "message",
1010
nestedKey: "payload"
11-
};
12-
13-
const devConfig = {
14-
level: "debug",
15-
transport: {
16-
target: "pino-pretty",
17-
options: {
18-
colorize: true,
19-
translateTime: "SYS:yyyy-mm-dd HH:MM:ss.l",
20-
ignore: "pid,hostname",
21-
messageKey: "message"
22-
}
23-
}
24-
};
25-
26-
const logger = pino(
27-
process.env.NODE_ENV === "production" ? prodConfig : devConfig
28-
);
11+
});
2912

3013
export default logger;

0 commit comments

Comments
 (0)