@iotile/iotile-common
Version:
Common utilities for IoTile Packages and Applications
52 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var typescript_logging_1 = require("typescript-logging");
var LoggingBase = /** @class */ (function () {
function LoggingBase(category) {
this.category = category;
}
/**
* @param level
* @param applyChildren default: fase. If set to `true` then the level will be set for all
* child categories.
*
* @description **WARNING**: This will override the entire category configuration, not just the LogLevel.
* **DO NOT** use in production.
*
* @todo Keep current config settings and only update LogLevel. It is not apparent how
* to do this and may require a PR for https://github.com/mreuvers/typescript-logging
*/
LoggingBase.prototype.setLogLevel = function (level, applyChildren) {
if (applyChildren === void 0) { applyChildren = false; }
typescript_logging_1.CategoryServiceFactory.setConfigurationCategory(new typescript_logging_1.CategoryConfiguration(level), this.category, applyChildren);
};
LoggingBase.prototype.buildLogMessage = function (msg, extraArgs) {
if (extraArgs == null)
extraArgs = undefined;
return {
msg: msg,
data: extraArgs
};
};
LoggingBase.prototype.logException = function (msg, error, extraArgs) {
this.category.error(this.buildLogMessage(msg, extraArgs), error);
};
LoggingBase.prototype.logError = function (msg, extraArgs) {
this.category.error(this.buildLogMessage(msg, extraArgs), null);
};
LoggingBase.prototype.logDebug = function (msg, extraArgs) {
this.category.debug(this.buildLogMessage(msg, extraArgs));
};
LoggingBase.prototype.logInfo = function (msg, extraArgs) {
this.category.info(this.buildLogMessage(msg, extraArgs));
};
LoggingBase.prototype.logTrace = function (msg, extraArgs) {
this.category.trace(this.buildLogMessage(msg, extraArgs));
};
LoggingBase.prototype.logWarning = function (msg, extraArgs) {
this.category.warn(this.buildLogMessage(msg, extraArgs));
};
return LoggingBase;
}());
exports.LoggingBase = LoggingBase;
//# sourceMappingURL=logging-base.js.map