zedai-voice
Version:
Siri-like voice banking SDK for React Native - Complete voice-powered fintech solution with wake word detection and beautiful UI
83 lines (82 loc) • 3.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
// src/utils/Logger.js
var Logger = /*#__PURE__*/function () {
function Logger() {
var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'info';
_classCallCheck(this, Logger);
this.level = level;
this.levels = {
error: 0,
warn: 1,
info: 2,
debug: 3
};
}
return _createClass(Logger, [{
key: "shouldLog",
value: function shouldLog(level) {
return this.levels[level] <= this.levels[this.level];
}
}, {
key: "formatMessage",
value: function formatMessage(level, message) {
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var timestamp = new Date().toISOString();
var contextStr = Object.keys(context).length > 0 ? JSON.stringify(context) : '';
return "[".concat(timestamp, "] [").concat(level.toUpperCase(), "] ").concat(message, " ").concat(contextStr);
}
}, {
key: "error",
value: function error(message) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.shouldLog('error')) {
console.error(this.formatMessage('error', message, context));
}
}
}, {
key: "warn",
value: function warn(message) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.shouldLog('warn')) {
console.warn(this.formatMessage('warn', message, context));
}
}
}, {
key: "info",
value: function info(message) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.shouldLog('info')) {
console.info(this.formatMessage('info', message, context));
}
}
}, {
key: "debug",
value: function debug(message) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this.shouldLog('debug')) {
console.debug(this.formatMessage('debug', message, context));
}
}
}, {
key: "setLevel",
value: function setLevel(level) {
if (this.levels.hasOwnProperty(level)) {
this.level = level;
} else {
this.warn("Invalid log level: ".concat(level, ". Using current level: ").concat(this.level));
}
}
}]);
}(); // Create a default logger instance
var logger = new Logger(__DEV__ ? 'debug' : 'info');
var _default = exports["default"] = logger;