Meriadec Pillet
6 years ago
committed by
GitHub
12 changed files with 96 additions and 109 deletions
@ -0,0 +1,16 @@ |
|||
import Transport from 'winston-transport' |
|||
|
|||
export default class InternalTransport extends Transport { |
|||
log(info, callback) { |
|||
setImmediate(() => { |
|||
this.emit('logged', info) |
|||
}) |
|||
|
|||
process.send({ |
|||
type: 'log', |
|||
log: info, |
|||
}) |
|||
|
|||
callback() |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
import Transport from 'winston-transport' |
|||
|
|||
export default class MainTransport extends Transport { |
|||
logs = [] |
|||
capacity = 2000 |
|||
|
|||
log(info, callback) { |
|||
setImmediate(() => { |
|||
this.emit('logged', info) |
|||
}) |
|||
|
|||
this.logs.unshift(info) |
|||
this.logs.splice(this.capacity) |
|||
|
|||
callback() |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
import Transport from 'winston-transport' |
|||
|
|||
export default class RendererTransport extends Transport { |
|||
ipcRenderer = require('electron').ipcRenderer |
|||
|
|||
log(info, callback) { |
|||
setImmediate(() => { |
|||
this.emit('logged', info) |
|||
}) |
|||
|
|||
this.ipcRenderer.send('log', { log: info }) |
|||
|
|||
callback() |
|||
} |
|||
} |
Loading…
Reference in new issue