mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
34 lines
631 B
TypeScript
34 lines
631 B
TypeScript
import { Stream } from 'stream';
|
|
|
|
export interface BunyanRecord extends Record<string, any> {
|
|
level: number;
|
|
msg: string;
|
|
module?: string;
|
|
}
|
|
|
|
const excludeProps = ['pid', 'time', 'v', 'hostname'];
|
|
|
|
export class ErrorStream extends Stream {
|
|
private _errors: BunyanRecord[] = [];
|
|
|
|
readable: boolean;
|
|
|
|
writable: boolean;
|
|
|
|
constructor() {
|
|
super();
|
|
this.readable = false;
|
|
this.writable = true;
|
|
}
|
|
|
|
write(data: BunyanRecord) {
|
|
const err = { ...data };
|
|
for (const prop of excludeProps) delete err[prop];
|
|
this._errors.push(err);
|
|
return true;
|
|
}
|
|
|
|
getErrors() {
|
|
return this._errors;
|
|
}
|
|
}
|