var logger,forge=require("./forge");require("./util"),module.exports=forge.log=forge.log||{},forge.log.levels=["none","error","warning","info","debug","verbose","max"];var sLevelInfo={},sLoggers=[],sConsoleLogger=null;forge.log.LEVEL_LOCKED=2,forge.log.NO_LEVEL_CHECK=4,forge.log.INTERPOLATE=8;for(var i=0;i<forge.log.levels.length;++i){var e=forge.log.levels[i];sLevelInfo[e]={index:i,name:e.toUpperCase()}}forge.log.logMessage=function(e){for(var o=sLevelInfo[e.level].index,l=0;l<sLoggers.length;++l){var g=sLoggers[l];g.flags&forge.log.NO_LEVEL_CHECK?g.f(e):o<=sLevelInfo[g.level].index&&g.f(g,e)}},forge.log.prepareStandard=function(e){"standard"in e||(e.standard=sLevelInfo[e.level].name+" ["+e.category+"] "+e.message)},forge.log.prepareFull=function(e){if(!("full"in e)){var o=[e.message];o=o.concat([]),e.full=forge.util.format.apply(this,o)}},forge.log.prepareStandardFull=function(e){"standardFull"in e||(forge.log.prepareStandard(e),e.standardFull=e.standard)};for(var levels=["error","warning","info","debug","verbose"],i=0;i<levels.length;++i)!function(e){forge.log[e]=function(o,l){var g=Array.prototype.slice.call(arguments).slice(2),r={timestamp:new Date,level:e,category:o,message:l,arguments:g};forge.log.logMessage(r)}}(levels[i]);if(forge.log.makeLogger=function(e){var o={flags:0,f:e};return forge.log.setLevel(o,"none"),o},forge.log.setLevel=function(e,o){var l=!1;if(e&&!(e.flags&forge.log.LEVEL_LOCKED)){for(var g=0;g<forge.log.levels.length;++g)if(o==forge.log.levels[g]){e.level=o,l=!0;break}}return l},forge.log.lock=function(e,o){void 0===o||o?e.flags|=forge.log.LEVEL_LOCKED:e.flags&=~forge.log.LEVEL_LOCKED},forge.log.addLogger=function(e){sLoggers.push(e)},"u">typeof console&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug){var o={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},l=function(e,l){forge.log.prepareStandard(l);var g=o[l.level],r=[l.standard];r=r.concat(l.arguments.slice()),g.apply(console,r)};logger=forge.log.makeLogger(l)}else{var l=function(e,o){forge.log.prepareStandardFull(o),console.log(o.standardFull)};logger=forge.log.makeLogger(l)}forge.log.setLevel(logger,"debug"),forge.log.addLogger(logger),sConsoleLogger=logger}else console={log:function(){}};if(null!==sConsoleLogger&&"u">typeof window&&window.location){var g=new URL(window.location.href).searchParams;if(g.has("console.level")&&forge.log.setLevel(sConsoleLogger,g.get("console.level").slice(-1)[0]),g.has("console.lock")){var r=g.get("console.lock").slice(-1)[0];"true"==r&&forge.log.lock(sConsoleLogger)}}forge.log.consoleLogger=sConsoleLogger;