import o from"chalk";var t={debug:0,info:1,warn:2,error:3,silent:4},s=class{constructor(){this._level=this._getLogLevel()}_getLogLevel(){if(process.env.ZIBBY_DEBUG==="true")return t.debug;if(process.env.ZIBBY_VERBOSE==="true")return t.info;let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in t?t[e]:t.info}_shouldLog(e){return t[e]>=this._level}_formatMessage(e,r,n={}){let l=new Date().toISOString(),i=`${this._getPrefix(e)} ${r}`;return Object.keys(n).length>0&&(i+=o.dim(` ${JSON.stringify(n)}`)),i}_getPrefix(e){return{debug:o.gray("[DEBUG]"),info:o.cyan("[INFO]"),warn:o.yellow("[WARN]"),error:o.red("\u274C [ERROR]")}[e]||""}debug(e,r){this._shouldLog("debug")&&console.log(this._formatMessage("debug",e,r))}info(e,r){this._shouldLog("info")&&console.log(this._formatMessage("info",e,r))}warn(e,r){this._shouldLog("warn")&&console.warn(this._formatMessage("warn",e,r))}error(e,r){this._shouldLog("error")&&console.error(this._formatMessage("error",e,r))}setLevel(e){e in t&&(this._level=t[e])}getLevel(){return Object.keys(t).find(e=>t[e]===this._level)}},_=new s;export{t as LOG_LEVELS,s as Logger,_ as logger};
