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:
parent
5b89bfce7c
commit
c1feaa4cb1
42 changed files with 3824 additions and 2422 deletions
|
|
@ -3,6 +3,9 @@
|
|||
import Twilio from "twilio";
|
||||
import { CallInstance } from "twilio/lib/rest/api/v2010/account/call";
|
||||
import { Zammad, getOrCreateUser } from "./zammad.js";
|
||||
import { createLogger } from "@link-stack/logger";
|
||||
|
||||
const logger = createLogger('bridge-worker-common');
|
||||
|
||||
type SavedVoiceProvider = any;
|
||||
|
||||
|
|
@ -63,7 +66,7 @@ export const createZammadTicket = async (
|
|||
});
|
||||
} catch (error: any) {
|
||||
if (error.isBoom) {
|
||||
console.error(error.output);
|
||||
logger.error({ output: error.output }, 'Zammad ticket creation failed');
|
||||
throw new Error("Failed to create zamamd ticket");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
//import { defState } from "@digiresilience/montar";
|
||||
//import { configureLogger } from "@digiresilience/bridge-common";
|
||||
// import config from "@digiresilience/bridge-config";
|
||||
|
||||
//export const logger = defState("workerLogger", {
|
||||
// start: async () => configureLogger(config),
|
||||
//});
|
||||
//export default logger;
|
||||
|
||||
export const logger = {};
|
||||
export default logger;
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
import { Readable } from "stream";
|
||||
import ffmpeg from "fluent-ffmpeg";
|
||||
import * as R from "remeda";
|
||||
import { createLogger } from "@link-stack/logger";
|
||||
|
||||
const logger = createLogger('bridge-worker-media-convert');
|
||||
|
||||
const requiredCodecs = ["mp3", "webm", "wav"];
|
||||
|
||||
|
|
@ -36,7 +39,7 @@ export const convert = (
|
|||
.audioBitrate(settings.bitrate)
|
||||
.toFormat(settings.format)
|
||||
.on("error", (err, _stdout, _stderr) => {
|
||||
console.error(err.message);
|
||||
logger.error({ error: err }, 'FFmpeg conversion error');
|
||||
reject(err);
|
||||
})
|
||||
.on("end", () => {
|
||||
|
|
@ -58,7 +61,7 @@ export const selfCheck = (): Promise<boolean> => {
|
|||
return new Promise((resolve) => {
|
||||
ffmpeg.getAvailableFormats((err, codecs) => {
|
||||
if (err) {
|
||||
console.error("FFMPEG error:", err);
|
||||
logger.error({ error: err }, 'FFMPEG error');
|
||||
resolve(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue