generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
githubActionsBunyanStream.ts
45 lines (38 loc) · 1003 Bytes
/
githubActionsBunyanStream.ts
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {ERROR, INFO, Stream, WARN} from 'bunyan'
import {BunyanRecord} from 'renovate/dist/logger/utils'
import * as core from '@actions/core'
import {Writable} from 'stream'
const messagesToIgnore = ['RE2 not usable, falling back to RegExp']
class GithubActionsStream extends Writable {
constructor() {
super({
objectMode: true
})
}
_write(rec: BunyanRecord, _: unknown, next: () => void): void {
if (messagesToIgnore.includes(rec.msg)) {
next()
return
}
const context = rec.module ? `[${rec.module}] ` : ''
const msg = `${context}${rec.msg}`
if (rec.level < INFO) {
core.debug(msg)
} else if (rec.level < WARN) {
core.info(msg)
} else if (rec.level < ERROR) {
core.warning(msg)
} else {
core.error(msg)
}
next()
}
}
export function createGithubActionsBunyanStream(): Stream {
return {
name: 'github-actions',
level: 'debug',
stream: new GithubActionsStream(),
type: 'raw'
}
}