authrix
Version:
Lightweight, flexible authentication library for Node.js and TypeScript.
1 lines • 993 B
JavaScript
var t={debug:10,info:20,warn:30,error:40};function a(){let o=(process.env.AUTHRIX_LOG_LEVEL||"").toLowerCase();return o==="debug"||o==="info"||o==="warn"||o==="error"?o:process.env.NODE_ENV==="production"?"info":"debug"}var r=class{constructor(e={}){this.namespace=e.namespace,this.level=e.level||a();}setLevel(e){this.level=e;}getLevel(){return this.level}shouldLog(e){return t[e]>=t[this.level]}fmt(e){return [this.namespace?`[AUTHRIX][${this.namespace}]`:"[AUTHRIX]",...e]}debug(...e){this.shouldLog("debug");}info(...e){this.shouldLog("info");}warn(...e){this.shouldLog("warn");}structuredWarn(e){if(!this.shouldLog("warn"))return;let {category:n,action:g,outcome:i,message:c,...l}=e;({...l});}error(...e){this.shouldLog("error");}},s=new r({namespace:"core"});function u(o,e){return new r({namespace:o,level:e})}function v(o){o?s.setLevel(o):s.setLevel(a());}process.env.AUTHRIX_DEBUG==="true"&&s.getLevel()!=="debug"&&s.setLevel("debug");exports.a=s;exports.b=u;exports.c=v;
;