diff options
Diffstat (limited to 'logger.js')
-rw-r--r-- | logger.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/logger.js b/logger.js new file mode 100644 index 0000000..ae44ae1 --- /dev/null +++ b/logger.js @@ -0,0 +1,28 @@ +/// <reference types="../CTAutocomplete" /> +/// <reference lib="es2015" /> + +class Logger{ + constructor(){ + this.loglevel = 4 //0=none, 1=error, 2=warn, 3=info, 4=debug + this.logToMcChat = false + this.logPrefixes = [ + "[SOOPYADDONS] ", + "[SOOPYADDONS:ERROR] ", + "[SOOPYADDONS:WARN] ", + "[SOOPYADDONS:INFO] ", + "[SOOPYADDONS:DEBUG] " + ] + this.logMessage("Logger initialised", 3) + } + + logMessage(message, level){ + if(level <= this.loglevel){ + console.log(this.logPrefixes[level] + message) + if(this.logToMcChat){ + ChatLib.chat(this.logPrefixes[level] + message) + } + } + } +} + +export default new Logger()
\ No newline at end of file |