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:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user