blob: e6e9fff400bbc4a1edf1a9ba12632b016d98995e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
export default class BasicReporter {
constructor (stream) {
this.stream = stream || process.stdout
}
formatTag (tag) {
return `[${tag.toUpperCase()}]`
}
log (logObj) {
let l = [this.formatTag(logObj.date.toLocaleTimeString())]
if (logObj.scope) {
l.push(this.formatTag(logObj.scope))
}
l.push(logObj.message)
this.stream.write(l.join(' ') + '\n')
if (logObj.additional) {
this.stream.write(logObj.additional + '\n')
}
}
}
|