Created
February 14, 2021 15:30
-
-
Save sualko/c894e5881b7c97f0c2cc66dba62de3c8 to your computer and use it in GitHub Desktop.
Print Nextcloud Log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
let logFile = process.argv[2] || './data/nextcloud.log'; | |
fs.readFile(logFile, 'utf8', function (err, data) { | |
if (err) throw err; | |
data.split('\n').forEach((line) => { | |
if (!line) return; | |
try { | |
let data = JSON.parse(line); | |
console.log(new Date(data.time), data.reqId, data.level, data.app, data.message); | |
}catch(err) { | |
console.warn('ERROR', err); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment