* logger
| 84 | * logger |
| 85 | */ |
| 86 | class Logger { |
| 87 | static generatorStyle(style = []) { |
| 88 | return style.join(";") |
| 89 | } |
| 90 | static changeStyle = (input, style) => `\x1b[${this.generatorStyle(style)}m${input}\x1b[0m` |
| 91 | static bColorMap = { |
| 92 | black: "40", |
| 93 | red: "41", |
| 94 | green: "42", |
| 95 | yellow: "43", |
| 96 | blue: "44", |
| 97 | magenta: "45", |
| 98 | cyan: "46", |
| 99 | white: "47", |
| 100 | } |
| 101 | static fColorMap = { |
| 102 | black: "30", |
| 103 | red: "31", |
| 104 | green: "32", |
| 105 | yellow: "33", |
| 106 | blue: "34", |
| 107 | magenta: "35", |
| 108 | cyan: "36", |
| 109 | white: "37", |
| 110 | } |
| 111 | static red(text, f = false) { |
| 112 | return this.changeStyle(text, f ? [this.fColorMap.red] : [this.fColorMap.white, this.bColorMap.red]) |
| 113 | } |
| 114 | static green(text, f = false) { |
| 115 | return this.changeStyle(text, f ? [this.fColorMap.green] : [this.fColorMap.white, this.bColorMap.green]) |
| 116 | } |
| 117 | static yellow(text, f = false) { |
| 118 | return this.changeStyle(text, f ? [this.fColorMap.yellow] : [this.fColorMap.white, this.bColorMap.yellow]) |
| 119 | } |
| 120 | static blue(text, f = false) { |
| 121 | return this.changeStyle(text, f ? [this.fColorMap.blue] : [this.fColorMap.white, this.bColorMap.blue]) |
| 122 | } |
| 123 | static logError(...args) { |
| 124 | console.error(`${this.red("Error: ")}`, ...args) |
| 125 | } |
| 126 | static logWarn(...args) { |
| 127 | console.warn(`${this.yellow("Warning: ")}`, ...args) |
| 128 | } |
| 129 | static logInfo(...args) { |
| 130 | console.info(`${this.blue("Info: ")}`, ...args) |
| 131 | } |
| 132 | static logSuccess(...args) { |
| 133 | console.log(`${this.green("Success: ")}`, ...args) |
| 134 | } |
| 135 | static log(...arg) { |
| 136 | console.log(...arg) |
| 137 | } |
| 138 | static table(...arg) { |
| 139 | console.table(...arg) |
| 140 | } |
| 141 | } |
| 142 | /** |
| 143 | * environment variable |
nothing calls this directly
no test coverage detected