feat(logs): enhance the logs and add a prefix with the issue number (#222)

* feat(logs): enhance the logs and add a prefix with the issue number

* chore: use camelCase for constants

use the new logger for the new code due to the rebase
This commit is contained in:
Geoffrey Testelin
2021-01-16 09:49:50 -05:00
committed by GitHub
parent 552e4c60f0
commit e6b77bc964
5 changed files with 273 additions and 48 deletions
+31
View File
@@ -0,0 +1,31 @@
import * as core from '@actions/core';
import {Issue} from '../IssueProcessor';
import {Logger} from './logger';
export class IssueLogger implements Logger {
private readonly _issue: Issue;
constructor(issue: Readonly<Issue>) {
this._issue = issue;
}
warning(message: Readonly<string>): void {
core.warning(this._prefixWithIssueNumber(message));
}
info(message: Readonly<string>): void {
core.info(this._prefixWithIssueNumber(message));
}
error(message: Readonly<string>): void {
core.error(this._prefixWithIssueNumber(message));
}
private _prefixWithIssueNumber(message: Readonly<string>): string {
return `[#${this._getIssueNumber()}] ${message}`;
}
private _getIssueNumber(): number {
return this._issue.number;
}
}