Skip to content

Commit

Permalink
rka-34: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
konstrybakov committed Jun 12, 2024
1 parent 87ef8c8 commit f628059
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
32 changes: 29 additions & 3 deletions lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
import { pino } from 'pino'
import { type TransportTargetOptions, pino } from 'pino'

export const logger = pino({
level: process.env.LOG_LEVEL || 'info',
const targets: TransportTargetOptions[] = [
{
target: 'pino-pretty',
options: {
colorize: true,
},
},
]

if (process.env.NODE_ENV === 'production') {
targets.push({
target: '@axiomhq/pino',
options: {
dataset: process.env.AXIOM_DATASET,
token: process.env.AXIOM_API_TOKEN,
},
})
}

const transport = pino.transport({
targets,
})

export const logger = pino(
{
level: process.env.LOG_LEVEL || 'info',
},
transport,
)
6 changes: 5 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['pino', 'pino-pretty', '@axiomhq/pino']
}
};

export default nextConfig;
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "PORT=4000 next dev | pino-pretty",
"dev": "PORT=4000 next dev",
"build": "next build",
"build:vercel": "bun db:migrate && next build",
"start": "next start",
"lint": "next lint",
"typecheck": "tsc --noEmit",
"db:generate": "drizzle-kit generate --config drizzle.config.ts",
"db:migrate": "bun run lib/db/migrate.ts | pino-pretty",
"db:reset": "bun run lib/db/reset.ts | pino-pretty",
"db:migrate": "bun run lib/db/migrate.ts",
"db:reset": "bun run lib/db/reset.ts",
"prepare": "husky"
},
"dependencies": {
"@axiomhq/pino": "^1.0.0-rc.4",
"@clerk/nextjs": "^5.1.4",
"@hookform/resolvers": "^3.4.2",
"@neondatabase/serverless": "^0.9.3",
Expand Down

0 comments on commit f628059

Please sign in to comment.