Skip to content
Snippets Groups Projects
Commit 0f5f7351 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

Monster/ /a7dcfcba f2e4 4fe3 8cdd 2b4eb084f0fd

parent 062c57b0
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 20 deletions
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{Base}from"../types/base.js";import{ALL,DEBUG,ERROR,FATAL,INFO,OFF,TRACE,WARN}from"./logger.js";import{LogEntry}from"./logentry.js";import{validateInstance,validateInteger}from"../types/validate.js";class Handler extends Base{constructor(){super(),this.loglevel=OFF}log(e){return validateInstance(e,LogEntry),!(this.loglevel<e.getLogLevel())}setLogLevel(e){return validateInteger(e),this.loglevel=e,this}getLogLevel(){return this.loglevel}setAll(){return this.setLogLevel(ALL),this}setTrace(){return this.setLogLevel(TRACE),this}setDebug(){return this.setLogLevel(DEBUG),this}setInfo(){return this.setLogLevel(INFO),this}setWarn(){return this.setLogLevel(WARN),this}setError(){return this.setLogLevel(ERROR),this}setFatal(){return this.setLogLevel(FATAL),this}setOff(){return this.setLogLevel(OFF),this}}Monster.assignToNamespace("Monster.Logging",Handler);export{Monster,Handler};
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../../namespace.js";import{Base}from"../../types/base.js";import{Handler}from"../../logging/handler.js";class ConsoleHandler extends Base{constructor(){super()}}Monster.assignToNamespace("Monster.Logging",ConsoleHandler);export{Monster,Handler};
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Logging.Handler";
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{validateInteger}from"../types/validate.js";import{Base}from"../types/base.js";class LogEntry extends Base{constructor(e,...t){super(),validateInteger(e),this.loglevel=e,this.arguments=t}getLogLevel(){return this.loglevel}getArguments(){return this.arguments}}Monster.assignToNamespace("Monster.Logging",LogEntry);export{Monster,LogEntry};
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{validateInteger,validateObject,validateString}from"../types/validate.js";import{Handler}from"../logging/handler.js";import{LogEntry}from"../logging/logentry.js";import{Base}from"../types/base.js";const ALL=255,TRACE=64,DEBUG=32,INFO=16,WARN=8,ERROR=4,FATAL=2,OFF=0;class Logger extends Base{constructor(){super(),this.handler=new Set}addHandler(r){if(validateObject(r),!(r instanceof Handler))throw new Error("the handler must be an instance of Handler");return this.handler.add(r),this}removeHandler(r){if(validateObject(r),!(r instanceof Handler))throw new Error("the handler must be an instance of Handler");return this.handler.delete(r),this}logTrace(){return triggerLog.apply(this,[TRACE,...arguments]),this}logDebug(){return triggerLog.apply(this,[DEBUG,...arguments]),this}logInfo(){return triggerLog.apply(this,[INFO,...arguments]),this}logWarn(){return triggerLog.apply(this,[WARN,...arguments]),this}logError(){return triggerLog.apply(this,[ERROR,...arguments]),this}logFatal(){return triggerLog.apply(this,[FATAL,...arguments]),this}getLabel(r){return validateInteger(r),r===ALL?"ALL":r===TRACE?"TRACE":r===DEBUG?"DEBUG":r===INFO?"INFO":r===WARN?"WARN":r===ERROR?"ERROR":r===FATAL?"FATAL":r===OFF?"OFF":"unknown"}getLevel(r){return validateString(r),"ALL"===r?ALL:"TRACE"===r?TRACE:"DEBUG"===r?DEBUG:"INFO"===r?INFO:"WARN"===r?WARN:"ERROR"===r?ERROR:"FATAL"===r?FATAL:"OFF"===r?OFF:0}}function triggerLog(r,...e){var t;for(t of this.handler)t.log(new LogEntry(r,e));return this}Monster.assignToNamespace("Monster.Logging",Logger);export{Monster,Logger,ALL,TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF};
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Logging";
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Math";
\ No newline at end of file
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,getGlobal}from"../types/global.js";function random(r,t){if((t=void 0===t?MAX:t)<(r=void 0===r?0:r))throw new Error("max must be greater than min");return Math.round(create(r,t))}var MAX=1e9;function create(r,t){let e;var o=getGlobal();if(e=o?.crypto||o?.msCrypto||o?.crypto||void 0,void 0===e)throw new Error("missing crypt");let a=0;var n=t-r;if(n<2)throw new Error("the distance is too small to create a random number.");o=Math.ceil(Math.log2(n));if(53<o)throw new Error("we cannot generate numbers larger than 53 bits.");var i=Math.ceil(o/8),o=Math.pow(2,o)-1,s=new Uint8Array(i);e.getRandomValues(s);let l=8*(i-1);for(var h=0;h<i;h++)a+=s[h]*Math.pow(2,l),l-=8;return a&=o,a>=n?create(r,t):r+a}Math.log2=Math.log2||function(r){return Math.log(r)/Math.log(2)},Monster.assignToNamespace("Monster.Math",random);export{Monster,random};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";class Base extends Object{toString(){return JSON.stringify(this)}}Monster.assignToNamespace("Monster.Types",Base);export{Monster,Base};
\ No newline at end of file
This diff is collapsed.
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,Base}from"./base.js";import{validateString}from"./validate.js";let internalCounter=new Map;class ID extends Base{constructor(t){super(),void 0===t&&(t="id"),validateString(t),internalCounter.has(t)||internalCounter.set(t,1);var e=internalCounter.get(t);this.id=t+e,internalCounter.set(t,++e)}toString(){return this.id}}Monster.assignToNamespace("Monster.Types",ID);export{Monster,ID};
\ No newline at end of file
This diff is collapsed.
/** Monster 1.11.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
/** Monster 1.11.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Types";
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment