mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
Made logger interface
This commit is contained in:
parent
98b2172a77
commit
34b6c9b16e
4 changed files with 48 additions and 1 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -4,6 +4,11 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz",
|
||||
"integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ=="
|
||||
},
|
||||
"@babel/code-frame": {
|
||||
"version": "7.12.11",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
|
||||
|
|
|
@ -38,5 +38,7 @@
|
|||
"jest": "^27.2.2",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.5.0"
|
||||
}
|
||||
}
|
||||
|
|
33
src/utils/logger-utils.ts
Normal file
33
src/utils/logger-utils.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import * as actions from "@actions/core";
|
||||
import * as console from "console";
|
||||
import Logger from "./logger";
|
||||
|
||||
export function getDefaultLogger(): Logger {
|
||||
return {
|
||||
fatal: actions.setFailed,
|
||||
error: actions.warning,
|
||||
warn: actions.warning,
|
||||
info: actions.info,
|
||||
debug: actions.debug
|
||||
};
|
||||
}
|
||||
|
||||
export function getConsoleLogger(): Logger {
|
||||
return {
|
||||
fatal: console.error,
|
||||
error: console.error,
|
||||
warn: console.warn,
|
||||
info: console.info,
|
||||
debug: console.debug
|
||||
};
|
||||
}
|
||||
|
||||
export function getEmptyLogger(): Logger {
|
||||
return {
|
||||
fatal: () => {},
|
||||
error: () => {},
|
||||
warn: () => {},
|
||||
info: () => {},
|
||||
debug: () => {}
|
||||
};
|
||||
}
|
7
src/utils/logger.ts
Normal file
7
src/utils/logger.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export default interface Logger {
|
||||
fatal(message: string | Error): void;
|
||||
error(message: string | Error): void;
|
||||
warn(message: string | Error): void;
|
||||
info(message: string | Error): void;
|
||||
debug(message: string | Error): void;
|
||||
}
|
Loading…
Reference in a new issue