mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-27 00:48:41 +00:00
Implement logger
This commit is contained in:
parent
1a9ecd30c7
commit
7dbedb31dd
22
Log/LogLevel.enum.js
Normal file
22
Log/LogLevel.enum.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Log Level enum.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS, undefined)
|
||||
{
|
||||
jsOMS.EnumLogLevel = Object.freeze({
|
||||
EMERGENCY: 'normal',
|
||||
ALERT: 'normal',
|
||||
CRITICAL: 'normal',
|
||||
ERROR: 'normal',
|
||||
WARNING: 'normal',
|
||||
NOTICE: 'normal',
|
||||
INFO: 'normal',
|
||||
DEBUG: 'normal'
|
||||
});
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
102
Log/Logger.js
Normal file
102
Log/Logger.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* Logger class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS, undefined)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Logger = function (verbose, ui, remote)
|
||||
{
|
||||
this.verbose = typeof verbose !== 'undefined' ? verbose : true;
|
||||
this.ui = typeof ui !== 'undefined' ? ui : true;
|
||||
this.remote = typeof remote !== 'undefined' ? remote : false;
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.interpolate = function(message, context, level)
|
||||
{
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.write = function(message, context, level)
|
||||
{
|
||||
if(this.verbose) {
|
||||
console.log(this.interpolate(message, context, level)));
|
||||
}
|
||||
|
||||
if(this.ui) {
|
||||
// todo: fill log box, set class and initiate animation
|
||||
}
|
||||
|
||||
if(this.remote) {
|
||||
let request = new jsOMS.Request(),
|
||||
request.setData(message);
|
||||
request.setType('json');
|
||||
request.setUri(jsOMS.UriFactory.build('/{/lang}/api/log'));
|
||||
request.setMethod(jsOMS.EnumRequestMethod.POST);
|
||||
request.setRequestHeader('Content-Type', 'application/json');
|
||||
request.setSuccess(function (xhr) {});
|
||||
request.send();
|
||||
}
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.emergency = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.EMERGENCY)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.alert = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.ALERT)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.critical = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.CRITICAL)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.error = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.ERROR)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.warning = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.WARNING)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.notice = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.NOTICE)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.info = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.INFO)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.debug = function(message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.DEBUG)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.log = function(level, message, context)
|
||||
{
|
||||
this.write(message, context, context)
|
||||
};
|
||||
|
||||
jsOMS.FormManager.prototype.console = function(level, message, context)
|
||||
{
|
||||
this.write(message, context, jsOMS.EnumLogLevel.INFO)
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
Loading…
Reference in New Issue
Block a user