Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: logger options only accepts a configuration object #479 #480

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
name: Install pnpm
with:
version: 9
version: 9.14.2
- name: Install with pnpm
run: pnpm install --frozen-lockfile
- name: Check commit message
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
name: Install pnpm
with:
version: 9
version: 9.14.2
- name: Install with pnpm
run: pnpm install
- name: Lint code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
name: Install pnpm
with:
version: 9
version: 9.14.2
- name: Install dependencies
run: pnpm install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
name: Install pnpm
with:
version: 9
version: 9.14.2
- name: Install with pnpm
run: pnpm install
- name: Run tests with coverage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

![remote_cache_1](https://user-images.githubusercontent.com/1620916/216358421-36a63b0e-d1f6-484f-a4ca-6a7119cc0816.jpg)

[![GitHub package.json version](https://img.shields.io/github/package-json/v/ducktors/turborepo-remote-cache)](https://github.com/ducktors/turborepo-remote-cache/releases) [![CI](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml) [![Test](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/test.yaml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/test.yaml) [![Release](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml) [![Docker](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/bbb26ca5247dee70dde0/maintainability)](https://codeclimate.com/github/ducktors/turborepo-remote-cache/maintainability) [![Coverage Status](https://coveralls.io/repos/github/ducktors/turborepo-remote-cache/badge.svg?branch=main)](https://coveralls.io/github/ducktors/turborepo-remote-cache?branch=main) [![Docker Pulls](https://img.shields.io/docker/pulls/ducktors/turborepo-remote-cache?logo=docker)](https://hub.docker.com/r/ducktors/turborepo-remote-cache) [![npm](https://img.shields.io/npm/dt/turborepo-remote-cache)](https://www.npmjs.com/package/turborepo-remote-cache) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/ducktors/turborepo-remote-cache/badge)](https://securityscorecards.dev/viewer/?uri=github.com/ducktors/turborepo-remote-cache) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![GitHub package.json version](https://img.shields.io/github/package-json/v/ducktors/turborepo-remote-cache)](https://github.com/ducktors/turborepo-remote-cache/releases) ![node:20.13.1](https://img.shields.io/badge/node-20.13.1-lightgreen) ![pnpm@9.14.2](https://img.shields.io/badge/pnpm-9.14.2-yellow) [![CI](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml) [![Test](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/test.yaml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/test.yaml) [![Release](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml) [![Docker](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/bbb26ca5247dee70dde0/maintainability)](https://codeclimate.com/github/ducktors/turborepo-remote-cache/maintainability) [![Coverage Status](https://coveralls.io/repos/github/ducktors/turborepo-remote-cache/badge.svg?branch=main)](https://coveralls.io/github/ducktors/turborepo-remote-cache?branch=main) [![Docker Pulls](https://img.shields.io/docker/pulls/ducktors/turborepo-remote-cache?logo=docker)](https://hub.docker.com/r/ducktors/turborepo-remote-cache) [![npm](https://img.shields.io/npm/dt/turborepo-remote-cache)](https://www.npmjs.com/package/turborepo-remote-cache) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/ducktors/turborepo-remote-cache/badge)](https://securityscorecards.dev/viewer/?uri=github.com/ducktors/turborepo-remote-cache) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-30-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"fastify-plugin": "5.0.1",
"fs-blob-store": "6.0.0",
"hyperid": "3.1.1",
"pino": "9.5.0",
"pino-pretty": "13.0.0",
"pino": "^9.5.0",
"pino-pretty": "^13.0.0",
"s3-blob-store": "4.1.1"
},
"devDependencies": {
Expand Down Expand Up @@ -95,7 +95,7 @@
"homepage": "https://github.com/ducktors/turborepo-remote-cache#readme",
"engines": {
"node": ">=20.0.0",
"pnpm": ">=9.0.0"
"pnpm": ">=9.14.2"
},
"keywords": [
"turborepo",
Expand Down
14 changes: 4 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const uuid = hyperid({ urlSafe: true })

export function createApp(options: FastifyServerOptions = {}): FastifyInstance {
const app = Fastify({
logger,
loggerInstance: logger,
genReqId: () => uuid(),
...options,
})
Expand Down
41 changes: 16 additions & 25 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,25 @@ const PinoLevelToSeverityLookup = {
fatal: 'CRITICAL',
} as const

let logDestination

const env = _env.get()

if (env.LOG_MODE === 'file') {
logDestination = pino.destination(env.LOG_FILE)
} else if (env.LOG_MODE === 'stdout') {
logDestination = process.stdout
} else {
throw new Error('Invalid LOG_MODE. Allowed values are "file" or "stdout".')
}

export const logger = pino(
{
level: env.LOG_LEVEL,
messageKey: 'message',
redact: ['req.headers.authorization'],
formatters: {
level(label, number) {
return {
severity:
PinoLevelToSeverityLookup[label] || PinoLevelToSeverityLookup.info,
level: number,
}
},
export const logger = pino({
level: env.LOG_LEVEL,
messageKey: 'message',
redact: ['req.headers.authorization'],
formatters: {
level(label, number) {
return {
severity:
PinoLevelToSeverityLookup[label] || PinoLevelToSeverityLookup.info,
level: number,
}
},
},
logDestination,
)
transport:
env.LOG_MODE === 'file'
? { target: 'pino/file', options: { destination: env.LOG_FILE } }
: undefined,
})

export default logger
Loading