* Add critical logger for booking created log to prevent stdout buffering issues Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Add comment * Separate critialLogger into it's own file --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
25 lines
634 B
TypeScript
25 lines
634 B
TypeScript
import fs from "fs";
|
|
|
|
import logger from "./logger";
|
|
|
|
/** This should be used if we want to ensure a log statement is always executed.
|
|
*
|
|
* This should only be used server side
|
|
*/
|
|
export const criticalLogger = logger.getSubLogger({
|
|
name: "critical",
|
|
overwrite: {
|
|
transportJSON: (logObj) => {
|
|
const logString = JSON.stringify(logObj);
|
|
const buffer = Buffer.from(logString + "\n");
|
|
|
|
try {
|
|
fs.writeSync(process.stdout.fd, buffer);
|
|
} catch (error) {
|
|
console.log(`Critical logger: Failed to write log using fs.writeSync: ${error}`);
|
|
console.log(logString);
|
|
}
|
|
},
|
|
},
|
|
});
|