feat(logger): added pino in and removed all console logs

This commit is contained in:
2025-12-22 12:46:40 -06:00
parent a8c5aad833
commit 878c3b3638
9 changed files with 520 additions and 28 deletions

View File

@@ -1,7 +1,9 @@
import { createLogger } from "../logger/logger.controller.js";
interface Data {
success: boolean;
module: "system" | "ocp";
subModule?: "db" | "labeling" | "printer";
subModule: "db" | "labeling" | "printer";
level: "info" | "error" | "debug" | "fatal";
message: string;
data?: unknown[];
@@ -24,19 +26,20 @@ interface Data {
*/
export const returnFunc = (data: Data) => {
const notify = data.notify ? data.notify : false;
const log = createLogger({ module: data.module, subModule: data.subModule });
// handle the logging part
switch (data.level) {
case "info":
console.log({ notify: notify }, data.message);
log.info({ notify: notify }, data.message);
break;
case "error":
console.log({ notify: notify }, data.message);
log.error({ notify: notify, error: data.data }, data.message);
break;
case "debug":
console.log({ notify: notify }, data.message);
log.debug({ notify: notify }, data.message);
break;
case "fatal":
console.log({ notify: notify }, data.message);
log.fatal({ notify: notify }, data.message);
}
// api section to return