Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type LogLevel =
- | "emergency"
- | "alert"
- | "critical"
- | "error"
- | "warning"
- | "notice"
- | "info"
- | "debug";
- type LogList = {
- [key in LogLevel]: Array<string>;
- };
- export class Log {
- _logs: LogList = {
- emergency: [],
- alert: [],
- critical: [],
- error: [],
- warning: [],
- notice: [],
- info: [],
- debug: [],
- };
- constructor() {}
- add(level: LogLevel, message: string): void {
- this._logs[level].push(message);
- }
- emergency(message: string): void {
- this.add("emergency", message);
- }
- alert(message: string): void {
- this.add("alert", message);
- }
- critical(message: string): void {
- this.add("critical", message);
- }
- error(message: string): void {
- this.add("error", message);
- }
- warning(message: string): void {
- this.add("warning", message);
- }
- notice(message: string): void {
- this.add("notice", message);
- }
- info(message: string): void {
- this.add("notice", message);
- }
- debug(message: string): void {
- this.add("debug", message);
- }
- get logs(): LogList {
- return this._logs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement