feat(logger): added pino in and removed all console logs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user