Commit 3cdc9b23 authored by Thimo Kraemer's avatar Thimo Kraemer

Added method setLogLevel

parent b1a0112c
/*
* KSS-RPC v0.18-beta
* KSS-RPC v0.19-beta
*
* Copyright (c) 2017, joonis new media
* Author: Thimo Kraemer <thimo.kraemer@joonis.de>
......@@ -61,7 +61,7 @@
******************************************************************************************/
var kss = {
version: '0.18-beta',
version: '0.19-beta',
_initialized: false,
_ruleSheets: {},
_eventBinders: {},
......@@ -70,10 +70,10 @@ var kss = {
_actionProviders: {},
_paramProviders: {},
_stateVars: {},
_logging: 'warn',
_observer: null,
// Default configuration
useObserver: false,
logging: 'warn',
config: {
protocol: 'json-rpc', /* json-rpc | xml-rpc | url-encoded | json */
endpoint: '.',
......@@ -95,11 +95,7 @@ kss._init = function() {
// Setup logging
kss.createLogger(kss);
var loglevel = window.location.hash.match(/^#logging=([\w]+)/);
if (loglevel) {
kss.setSessionVar('kssLogging', loglevel[1]);
}
kss.logging = kss.getSessionVar('kssLogging') || kss.logging;
kss._logging = kss.getSessionVar('kssLogging') || kss._logging;
kss.log('Initializing KSS v' + kss.version + ' ...');
......@@ -442,7 +438,7 @@ kss._logLevels = ['none', 'error', 'warn', 'time', 'info', 'log', 'debug'];
kss._log = function(level, messages) {
var levels = kss._logLevels;
if (!window.console || levels.indexOf(level)
> levels.indexOf(kss.logging)) {
> levels.indexOf(kss._logging)) {
return;
}
// Convert arguments to array
......@@ -475,6 +471,13 @@ kss._log = function(level, messages) {
}
};
kss.setLogLevel = function(level) {
if (kss._logLevels.indexOf(level) < 0)
throw Error('Invalid loglevel "' + level + '"');
kss._logging = level;
kss.setSessionVar('kssLogging', level);
};
kss.createLogger = function(bindTo) {
bindTo = bindTo || {};
bindTo._log = kss._log;
......@@ -705,7 +708,7 @@ kss._EventHandler.prototype = {
logHandler: function (messages, level) {
messages.unshift('Event [' + this.eventname + ']:');
if (kss.logging == 'debug') {
if (kss._logging == 'debug') {
var pos = this.rule.position;
messages.push('\nRuleSheet: ' + this.rule.url);
messages.push('\nLine: ' + pos.start.line
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment