mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 16:27:22 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
38 lines
980 B
TypeScript
38 lines
980 B
TypeScript
import colors from "chalk";
|
|
import read from "read";
|
|
|
|
function timestamp() {
|
|
const datetime = new Date().toISOString().split(".")[0].replace("T", " ");
|
|
|
|
return colors.dim(datetime);
|
|
}
|
|
|
|
const log = {
|
|
/* eslint-disable no-console */
|
|
error(...args: string[]) {
|
|
console.error(timestamp(), colors.red("[ERROR]"), ...args);
|
|
},
|
|
warn(...args: string[]) {
|
|
console.error(timestamp(), colors.yellow("[WARN]"), ...args);
|
|
},
|
|
info(...args: string[]) {
|
|
console.log(timestamp(), colors.blue("[INFO]"), ...args);
|
|
},
|
|
debug(...args: string[]) {
|
|
console.log(timestamp(), colors.green("[DEBUG]"), ...args);
|
|
},
|
|
raw(...args: string[]) {
|
|
console.log(...args);
|
|
},
|
|
/* eslint-enable no-console */
|
|
|
|
prompt(
|
|
options: {prompt?: string; default?: string; text: string; silent?: boolean},
|
|
callback: (error, result, isDefault) => void
|
|
): void {
|
|
options.prompt = [timestamp(), colors.cyan("[PROMPT]"), options.text].join(" ");
|
|
read(options, callback);
|
|
},
|
|
};
|
|
|
|
export default log;
|