chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
43
packages/server/lib/pg-transport.js
Normal file
43
packages/server/lib/pg-transport.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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()
|
||||
}
|
||||
|
||||
logException (msg, meta, callback) {
|
||||
this.log('error', msg, meta, callback)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue