code refactor
This commit is contained in:
parent
8df955a372
commit
a7e1d3a1f0
|
@ -1,7 +1,8 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('ariaNgLogService', ['$log', 'moment', 'ariaNgConstants', 'ariaNgSettingService', function ($log, moment, ariaNgConstants, ariaNgSettingService) {
|
||||
angular.module('ariaNg').factory('ariaNgLogService', ['$log', 'moment', 'ariaNgConstants', function ($log, moment, ariaNgConstants) {
|
||||
var enableDebugLog = false;
|
||||
var cachedDebugLogs = [];
|
||||
|
||||
var createNewCacheLogItem = function (msg, level, obj) {
|
||||
|
@ -14,7 +15,7 @@
|
|||
};
|
||||
|
||||
var pushLogToCache = function (msg, level, obj) {
|
||||
if (!ariaNgSettingService.isEnableDebugMode()) {
|
||||
if (!enableDebugLog) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,8 +27,11 @@
|
|||
};
|
||||
|
||||
return {
|
||||
setEnableDebugLog: function (value) {
|
||||
enableDebugLog = value;
|
||||
},
|
||||
debug: function (msg, obj) {
|
||||
if (ariaNgSettingService.isEnableDebugMode()) {
|
||||
if (enableDebugLog) {
|
||||
if (obj) {
|
||||
$log.debug('[AriaNg Debug]' + msg, obj);
|
||||
} else {
|
||||
|
@ -65,7 +69,7 @@
|
|||
pushLogToCache(msg, 'ERROR', obj);
|
||||
},
|
||||
getDebugLogs: function () {
|
||||
if (ariaNgSettingService.isEnableDebugMode()) {
|
||||
if (enableDebugLog) {
|
||||
return cachedDebugLogs;
|
||||
} else {
|
||||
return [];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('ariaNgSettingService', ['$window', '$location', '$filter', '$translate', 'base64', 'amMoment', 'localStorageService', 'ariaNgConstants', 'ariaNgDefaultOptions', 'ariaNgLanguages', 'ariaNgCommonService', function ($window, $location, $filter, $translate, base64, amMoment, localStorageService, ariaNgConstants, ariaNgDefaultOptions, ariaNgLanguages, ariaNgCommonService) {
|
||||
angular.module('ariaNg').factory('ariaNgSettingService', ['$window', '$location', '$filter', '$translate', 'base64', 'amMoment', 'localStorageService', 'ariaNgConstants', 'ariaNgDefaultOptions', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgLogService', function ($window, $location, $filter, $translate, base64, amMoment, localStorageService, ariaNgConstants, ariaNgDefaultOptions, ariaNgLanguages, ariaNgCommonService, ariaNgLogService) {
|
||||
var browserFeatures = (function () {
|
||||
var supportLocalStroage = localStorageService.isSupported;
|
||||
var supportCookies = $window.navigator.cookieEnabled;
|
||||
|
@ -270,6 +270,7 @@
|
|||
},
|
||||
setDebugMode: function (value) {
|
||||
sessionSettings.debugMode = value;
|
||||
ariaNgLogService.setEnableDebugLog(value);
|
||||
},
|
||||
getTitle: function () {
|
||||
return getOption('title');
|
||||
|
|
Reference in a new issue