Skip to content

Instantly share code, notes, and snippets.

@sualko
Created February 14, 2021 15:30
Show Gist options
  • Save sualko/c894e5881b7c97f0c2cc66dba62de3c8 to your computer and use it in GitHub Desktop.
Save sualko/c894e5881b7c97f0c2cc66dba62de3c8 to your computer and use it in GitHub Desktop.
Print Nextcloud Log
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