-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk6_console.min.js
1 lines (1 loc) · 3.34 KB
/
k6_console.min.js
1
class k6_console{constructor(P={}){function T_name(t,i,s){return t?`self.${i}${s}`:`window[ '${i}${s}' ]`}this.prod=P.prod||P.production||!1,this.global=P.global||!0,this.worker=P.worker||!1,this.mobile=P.mobile||"bl",(!1==P.mobile||"false"==P.mobile)&&(this.mobile=!1),this.header=P.header||"K6",this.prefix=P.prefix||"",this.prod||console.warn("k6_console.js:",`Don't forget "production: true" or "const ${this.prefix}CD = null, ${this.prefix}FCD = ${this.prefix}FCE = ${this.prefix}FCW = ${this.prefix}FCG = ${this.prefix}FCGE = ${this.prefix}FCT = ${this.prefix}FCI = ${this.prefix}FCL = ${this.prefix}FCLR = () => {}" for the production mode.`),!this.worker&&this.mobile&&(this.FC=document.createElement("pre"),document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.FC)}),this.FC.id="k6_console",this.FC.style.position="fixed",this.FC.style.fontSize="12px",this.FC.style.lineHeight="1",this.FC.style.margin="8px",this.FC.style.padding="8px",this.FC.style.borderRadius="4px","tl"==this.mobile&&(this.FC.style.top=0,this.FC.style.left=0),"tr"==this.mobile&&(this.FC.style.top=0,this.FC.style.right=0),"bl"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.left=0),"br"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.right=0)),this.FM=(t,i,s,e=!0)=>{!this.worker&&this.mobile&&(this.FC.style.color=t,this.FC.style.backgroundColor=i,this.FC.innerText=e?JSON.stringify(s):s)},this.CD=!this.prod,this.FCD=this.prod?()=>{}:(...t)=>{console.debug(`%c${this.header}%s`,"color: white; background-color: magenta;","%c %s","",...t),this.FM("white","magenta",t)},this.FCE=this.prod?()=>{}:(...t)=>{console.error(`%c${this.header}%s`,"color: white; background-color: red ;","%c %s","",...t),this.FM("white","red",t)},this.FCW=this.prod?()=>{}:(...t)=>{console.warn(`%c${this.header}%s`,"color: black; background-color: yellow ;","%c %s","",...t),this.FM("black","yellow",t)},this.FCG=this.prod?()=>{}:(...t)=>{console.group(`%c${this.header}%s`,"color: white; background-color: grey ;","%c %s","",...t),this.FM("white","grey",t)},this.FCGE=this.prod?()=>{}:(...t)=>{console.groupEnd()},this.FCT=this.prod?()=>{}:(...t)=>{console.trace(`%c${this.header}%s`,"color: white; background-color: blue ;","%c %s","",...t),this.FM("white","blue",t)},this.FCI=this.prod?()=>{}:(...t)=>{console.info(`%c${this.header}%s`,"color: black; background-color: cyan ;","%c %s","",...t),this.FM("black","cyan",t)},this.FCL=this.prod?()=>{}:(...t)=>{console.log(`%c${this.header}%s`,"color: white; background-color: green ;","%c %s","",...t),this.FM("white","green",t)},this.FCLR=this.prod?()=>{}:t=>{let i=[],s=JSON.stringify(t,function t(t,s){if("object"==typeof s&&null!==s){if(-1!==i.indexOf(s))return;i.push(s)}return s});i=null,console.log(`%c${this.header}%s`,"color: white; background-color: black;","%c %s","",s),this.FM("white","black",s,!1)},this.global&&eval(`${T_name(this.worker,this.prefix,"CD")} = this.CD ;${T_name(this.worker,this.prefix,"FCD")} = this.FCD ;${T_name(this.worker,this.prefix,"FCE")} = this.FCE ;${T_name(this.worker,this.prefix,"FCW")} = this.FCW ;${T_name(this.worker,this.prefix,"FCG")} = this.FCG ;${T_name(this.worker,this.prefix,"FCGE")} = this.FCGE;${T_name(this.worker,this.prefix,"FCT")} = this.FCT ;${T_name(this.worker,this.prefix,"FCI")} = this.FCI ;${T_name(this.worker,this.prefix,"FCL")} = this.FCL ;${T_name(this.worker,this.prefix,"FCLR")} = this.FCLR;`)}}