2021-01-16 15:49:50 +01:00
|
|
|
import * as core from '@actions/core';
|
2021-03-08 11:56:52 +01:00
|
|
|
import terminalLink from 'terminal-link';
|
|
|
|
|
import {Option} from '../../enums/option';
|
2021-06-02 23:04:34 +02:00
|
|
|
import {LoggerService} from '../../services/logger.service';
|
2021-01-16 15:49:50 +01:00
|
|
|
|
|
|
|
|
export class Logger {
|
2021-03-08 11:56:52 +01:00
|
|
|
warning(...message: string[]): void {
|
2021-06-02 23:04:34 +02:00
|
|
|
core.warning(LoggerService.whiteBright(message.join(' ')));
|
2021-01-16 15:49:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 11:56:52 +01:00
|
|
|
info(...message: string[]): void {
|
2021-06-02 23:04:34 +02:00
|
|
|
core.info(LoggerService.whiteBright(message.join(' ')));
|
2021-01-16 15:49:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 11:56:52 +01:00
|
|
|
error(...message: string[]): void {
|
2021-06-02 23:04:34 +02:00
|
|
|
core.error(LoggerService.whiteBright(message.join(' ')));
|
2021-03-08 11:56:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-07 23:22:55 +02:00
|
|
|
async grouping(message: string, fn: () => Promise<void>): Promise<void> {
|
|
|
|
|
return core.group(LoggerService.whiteBright(message), fn);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 11:56:52 +01:00
|
|
|
createLink(name: Readonly<string>, link: Readonly<string>): string {
|
|
|
|
|
return terminalLink(name, link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createOptionLink(option: Readonly<Option>): string {
|
2021-06-02 23:04:34 +02:00
|
|
|
return LoggerService.magenta(
|
2021-03-08 11:56:52 +01:00
|
|
|
this.createLink(option, `https://github.com/actions/stale#${option}`)
|
|
|
|
|
);
|
2021-01-16 15:49:50 +01:00
|
|
|
}
|
|
|
|
|
}
|