PINO JSON logging

This commit is contained in:
Jan Prochazka
2023-01-21 17:32:28 +01:00
parent dd230b008f
commit 4d93be61b5
47 changed files with 429 additions and 113 deletions

View File

@@ -1,5 +1,8 @@
const fs = require('fs');
const stream = require('stream');
const { getLogger } = global.DBGATE_TOOLS;
const logger = getLogger();
function escapeXml(value) {
return value.replace(/[<>&'"]/g, function (c) {
@@ -67,7 +70,7 @@ class StringifyStream extends stream.Transform {
}
async function writer({ fileName, encoding = 'utf-8', itemElementName, rootElementName }) {
console.log(`Writing file ${fileName}`);
logger.info(`Writing file ${fileName}`);
const stringify = new StringifyStream({ itemElementName, rootElementName });
const fileStream = fs.createWriteStream(fileName, encoding);
stringify.pipe(fileStream);