feat: add new server log page

This commit is contained in:
Luis Félix 2019-11-12 11:15:00 +00:00
parent fc1951c4b2
commit 703c5d7c91
38 changed files with 2844 additions and 29 deletions

39
lib/pg-transport.js Normal file
View file

@ -0,0 +1,39 @@
const Transport = require('winston-transport')
const eventBus = require('./event-bus')
//
// Inherit from `winston-transport` so you can take advantage
// of the base functionality and `.exceptions.handle()`.
//
module.exports = class CustomTransport extends Transport {
constructor (opts) {
super(opts)
//
// Consume any custom options here. e.g.:
// - Connection information for databases
// - Authentication information for APIs (e.g. loggly, papertrail,
// logentries, etc.).
//
this.tableName = opts.tableName || 'winston_logs'
if (!opts.connectionString) {
throw new Error('You have to define connectionString')
}
this.connectionString = opts.connectionString
}
log (level, message, meta, callback) {
if (!callback) callback = () => {}
setImmediate(() => {
this.emit('logged', level, message, meta)
})
// Perform the writing to the remote service
eventBus.publish('log', { level, message, meta })
callback()
}
}