feat: Add centralized logging system with @link-stack/logger package

- Create new @link-stack/logger package wrapping Pino for structured logging
- Replace all console.log/error/warn statements across the monorepo
- Configure environment-aware logging (pretty-print in dev, JSON in prod)
- Add automatic redaction of sensitive fields (passwords, tokens, etc.)
- Remove dead commented-out logger file from bridge-worker
- Follow Pino's standard argument order (context object first, message second)
- Support log levels via LOG_LEVEL environment variable
- Export TypeScript types for better IDE support

This provides consistent, structured logging across all applications
and packages, making debugging easier and production logs more parseable.
This commit is contained in:
Darren Clarke 2025-08-20 11:37:39 +02:00
parent 5b89bfce7c
commit c1feaa4cb1
42 changed files with 3824 additions and 2422 deletions

View file

@ -10,6 +10,9 @@ import {
CamelCasePlugin,
} from "kysely";
import pkg from "pg";
import { createLogger } from "@link-stack/logger";
const logger = createLogger('bridge-migrations-migrate');
const { Pool } = pkg;
import * as dotenv from "dotenv";
@ -72,17 +75,17 @@ export const migrate = async (arg: string) => {
results?.forEach((it) => {
if (it.status === "Success") {
console.info(
logger.info(
`Migration "${it.migrationName} ${it.direction.toLowerCase()}" was executed successfully`,
);
} else if (it.status === "Error") {
console.error(`Failed to execute migration "${it.migrationName}"`);
logger.error(`Failed to execute migration "${it.migrationName}"`);
}
});
if (error) {
console.error("Failed to migrate");
console.error(error);
logger.error("Failed to migrate");
logger.error(error);
process.exit(1);
}

View file

@ -9,6 +9,7 @@
"migrate:down:one": "tsx migrate.ts down:one"
},
"dependencies": {
"@link-stack/logger": "*",
"dotenv": "^16.4.7",
"kysely": "0.27.6",
"pg": "^8.14.1",