-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogUtils.js
More file actions
5 lines (4 loc) · 2.42 KB
/
Copy pathlogUtils.js
File metadata and controls
5 lines (4 loc) · 2.42 KB
1
2
3
4
5
/* mobilecaddy-utils - v3.2.1 - Bundle Time: 2024-10-22 11:36:49 */
/* git info: "2024-10-22 11:34:11 +0100": 4b69821f8a37db692d32cb588a22dc57e260d69b (v3) */
/* Copyright 2024 MobileCaddy Ltd */
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.debug=debug,exports.error=error,exports.errorAndDispatch=errorAndDispatch,exports.info=info,exports.log=log,exports.warn=warn,exports.doLog=doLog;var LOG_LEVEL_ERROR=0,LOG_LEVEL_WARN=1,LOG_LEVEL_LOG=2,LOG_LEVEL_INFO=3,LOG_LEVEL_DEBUG=4;function createLog(e,o){return new Promise(function(t,r){if(1==o.length&&(o=o[0]),"object"==_typeof(o)&&(o=JSON.stringify(o)),"number"!=typeof o&&"boolean"!=typeof o||(o=o.toString()),"string"==typeof o){e==LOG_LEVEL_ERROR&&localStorage.setItem("lastErrorLog",o.substring(0,1024));var n={mobilecaddy1__Error_Text__c:o.substring(0,1024),SystemModstamp:(new Date).getTime()},L=localStorage.getItem("appSoup-audId");n.mobilecaddy1__Application_User_Device__c=L,n.mobilecaddy1__Log_Type__c="D"+e.toString(),t(n)}else r("Trying to log unsupported type"+_typeof(o))})}function doLog(e,o,t,r){return new Promise(function(n,L){var c=localStorage.getItem("logLevel");c=null===c||void 0==_typeof(c)?0:c;if(o>0){var i=r.stack.split("\n")[4];if(void 0!==i){var _=i.indexOf("at ");i.slice(_+2,i.length)}}var a=t[0];switch(o){case LOG_LEVEL_ERROR:t[0]&&t[0].stack?a=t[0].message+", STACK:"+t[0].stack:t[1]&&t[1].stack?a+="\n"+t[1].message+", STACK:"+t[1].stack:a=t,createLog(o,a).then(function(e){n(e)});break;case LOG_LEVEL_WARN:case LOG_LEVEL_LOG:createLog(o,t).then(function(e){n(e)});break;default:createLog(o,t).then(function(e){n(e)})}e&&"undefined"!=typeof LOCAL_DEV&&LOCAL_DEV&&alert(a+"\n\nSee dev console for more information")})}function getErrorObject(){try{throw Error("")}catch(e){return e}}function debug(e){return doLog(!1,LOG_LEVEL_DEBUG,arguments,getErrorObject())}function error(e){return doLog(!1,LOG_LEVEL_ERROR,arguments)}function errorAndDispatch(e){return doLog(!0,LOG_LEVEL_ERROR,arguments)}function info(e){return doLog(!1,LOG_LEVEL_INFO,arguments,getErrorObject())}function log(e){return doLog(!1,LOG_LEVEL_LOG,arguments,getErrorObject())}function warn(e){return doLog(!1,LOG_LEVEL_WARN,arguments,getErrorObject())}