diff --git a/bower.json b/bower.json index 5177774..520dc3a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-logger", - "version": "1.0.0", + "version": "1.0.4", "repository": { "type": "git", "url": "https://github.com/better-js-logging/angular-logger.git" diff --git a/dist/angular-logger.js b/dist/angular-logger.js index 7b92bf1..3af6afe 100644 --- a/dist/angular-logger.js +++ b/dist/angular-logger.js @@ -61,6 +61,7 @@ var LoggingEnhancer = require('../bower_components/better-logging-base/dist/logg config(['$provide', 'logEnhancerProvider', function ($provide, p) { $provide.decorator('$log', ['$delegate', function ($delegate) { + $delegate.logLevels = p.logLevels; // copy the initial loglevel config return { // keep original methods, otherwise the enhanced functions on .getInstance() will have a double (global context) prefix $$orig$log: angular.extend({}, $delegate), diff --git a/dist/angular-logger.min.js b/dist/angular-logger.min.js index ebcc972..5947923 100644 --- a/dist/angular-logger.min.js +++ b/dist/angular-logger.min.js @@ -1 +1 @@ -!function e(n,t,r){function o(a,g){if(!t[a]){if(!n[a]){var l="function"==typeof require&&require;if(!g&&l)return l(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=t[a]={exports:{}};n[a][0].call(u.exports,function(e){var t=n[a][1][e];return o(t?t:e)},u,u.exports,e,n,t,r)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a ",this.LEVEL=e.LEVEL,this.logLevels={"*":this.LEVEL.TRACE},this.$get=function(){return{enhanceAngularLog:function(t){t.LEVEL=n.LEVEL,t.logLevels=n.logLevels,t.getInstance=function(r){return{trace:e.enhanceLogging(t.$$orig$log.debug,t.LEVEL.TRACE,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),debug:e.enhanceLogging(t.$$orig$log.debug,t.LEVEL.DEBUG,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),log:e.enhanceLogging(t.$$orig$log.log,t.LEVEL.INFO,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),info:e.enhanceLogging(t.$$orig$log.info,t.LEVEL.INFO,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),warn:e.enhanceLogging(t.$$orig$log.warn,t.LEVEL.WARN,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),error:e.enhanceLogging(t.$$orig$log.error,t.LEVEL.ERROR,r,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern)}}}}}}).config(["logEnhancerProvider",function(e){e.datetimePattern="LLL",e.datetimeLocale=window.navigator.userLanguage||window.navigator.language||"en",e.prefixPattern="%s::[%s]> ",e.logLevels={"*":e.LEVEL.TRACE}}]).config(["$provide","logEnhancerProvider",function(t,r){t.decorator("$log",["$delegate",function(t){return{$$orig$log:n.extend({},t),trace:e.enhanceLogging(t.debug,r.LEVEL.TRACE,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern),debug:e.enhanceLogging(t.debug,r.LEVEL.DEBUG,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern),log:e.enhanceLogging(t.log,r.LEVEL.INFO,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern),info:e.enhanceLogging(t.info,r.LEVEL.INFO,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern),warn:e.enhanceLogging(t.warn,r.LEVEL.WARN,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern),error:e.enhanceLogging(t.error,r.LEVEL.ERROR,"global",t,r.datetimePattern,r.datetimeLocale,r.prefixPattern)}}])}]).run(["$log","logEnhancer",function(e,n){t||e.warn('sprintf.js not found: https://github.com/alexei/sprintf.js, using fixed layout pattern "%s::[%s]> "'),r||e.warn("moment.js not found: http://momentjs.com, using non-localized simple Date format"),n.enhanceAngularLog(e),e.info("logging enhancer initiated")}])}(new r(window.sprintf,window.moment),window.angular,window.sprintf,window.moment)},{"../bower_components/better-logging-base/dist/logging-enhancer.min":2}],2:[function(e,n,t){!function(){"use strict";var e=function(e,n){var t=this;this.LEVEL={TRACE:4,DEBUG:3,INFO:2,WARN:1,ERROR:0,OFF:-1},this.enhanceLogging=function(r,o,i,a,g,l,c){function u(e,n,r){function o(e,n){if(e){if(void 0!==n.logLevels[e])return n.logLevels[e];if(-1!==e.indexOf("."))return o(e.substring(0,e.lastIndexOf(".")),n)}return void 0!==n.logLevels["*"]?n.logLevels["*"]:t.LEVEL.TRACE}return n>t.LEVEL.OFF&&n<=o(e,r)}function f(n,r,o,i,a){function g(n){var r="undefined"!=typeof e,o=r&&n.length>=2&&"string"==typeof n[0]&&-1!==n[0].indexOf("%");if(o)try{var i=t.countSprintfHolders(n[0]);i>0&&(n[0]=e.apply(null,n),n.splice(1,i))}catch(a){n.unshift(a)}return n}var l=L(r,o,i,a),c=g([].slice.call(n));return[l].concat([].slice.call(c))}function L(t,r,o,i){var a="";if("undefined"!=typeof n)a=n().locale(o).format(r);else{var g=new Date,l=(new Date).toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0];a=g.getDate()+"-"+(g.getMonth()+1)+"-"+g.getFullYear()+" "+l}return"undefined"!=typeof e?e(i,a,t):a+"::["+t+"]> "}return a.logLevels=a.logLevels||[],function(){if(u(i,o,a)){var e=f(arguments,i,g,l,c);return r.apply(null,e),e}return null}},t.countSprintfHolders=function(n){function t(e){return function(){o=Math.max(o,e)}}var r=/\x25\([a-zA-Z0-9_]+\)[b-fijosuxX]/.test(n);if(r)return 1;var o=0;return e(n,t(1),t(2),t(3),t(4),t(5),t(6),t(7),t(8),t(9),t(10)),o}};if("undefined"!=typeof n)n.exports.LoggingEnhancer=e;else if("undefined"!=typeof t)t.LoggingEnhancer=e;else{if("undefined"==typeof window)throw new Error("unable to expose LoggingEnhancer: no module, exports object and no global window detected");window.loggingEnhancer=new e(window.sprintf,window.moment)}}()},{}]},{},[1]); \ No newline at end of file +!function e(n,t,o){function r(a,g){if(!t[a]){if(!n[a]){var l="function"==typeof require&&require;if(!g&&l)return l(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=t[a]={exports:{}};n[a][0].call(u.exports,function(e){var t=n[a][1][e];return r(t?t:e)},u,u.exports,e,n,t,o)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a ",this.LEVEL=e.LEVEL,this.logLevels={"*":this.LEVEL.TRACE},this.$get=function(){return{enhanceAngularLog:function(t){t.LEVEL=n.LEVEL,t.logLevels=n.logLevels,t.getInstance=function(o){return{trace:e.enhanceLogging(t.$$orig$log.debug,t.LEVEL.TRACE,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),debug:e.enhanceLogging(t.$$orig$log.debug,t.LEVEL.DEBUG,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),log:e.enhanceLogging(t.$$orig$log.log,t.LEVEL.INFO,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),info:e.enhanceLogging(t.$$orig$log.info,t.LEVEL.INFO,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),warn:e.enhanceLogging(t.$$orig$log.warn,t.LEVEL.WARN,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern),error:e.enhanceLogging(t.$$orig$log.error,t.LEVEL.ERROR,o,t,n.datetimePattern,n.datetimeLocale,n.prefixPattern)}}}}}}).config(["logEnhancerProvider",function(e){e.datetimePattern="LLL",e.datetimeLocale=window.navigator.userLanguage||window.navigator.language||"en",e.prefixPattern="%s::[%s]> ",e.logLevels={"*":e.LEVEL.TRACE}}]).config(["$provide","logEnhancerProvider",function(t,o){t.decorator("$log",["$delegate",function(t){return t.logLevels=o.logLevels,{$$orig$log:n.extend({},t),trace:e.enhanceLogging(t.debug,o.LEVEL.TRACE,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern),debug:e.enhanceLogging(t.debug,o.LEVEL.DEBUG,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern),log:e.enhanceLogging(t.log,o.LEVEL.INFO,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern),info:e.enhanceLogging(t.info,o.LEVEL.INFO,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern),warn:e.enhanceLogging(t.warn,o.LEVEL.WARN,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern),error:e.enhanceLogging(t.error,o.LEVEL.ERROR,"global",t,o.datetimePattern,o.datetimeLocale,o.prefixPattern)}}])}]).run(["$log","logEnhancer",function(e,n){t||e.warn('sprintf.js not found: https://github.com/alexei/sprintf.js, using fixed layout pattern "%s::[%s]> "'),o||e.warn("moment.js not found: http://momentjs.com, using non-localized simple Date format"),n.enhanceAngularLog(e),e.info("logging enhancer initiated")}])}(new o(window.sprintf,window.moment),window.angular,window.sprintf,window.moment)},{"../bower_components/better-logging-base/dist/logging-enhancer.min":2}],2:[function(e,n,t){!function(){"use strict";var e=function(e,n){var t=this;this.LEVEL={TRACE:4,DEBUG:3,INFO:2,WARN:1,ERROR:0,OFF:-1},this.enhanceLogging=function(o,r,i,a,g,l,c){function u(e,n,o){function r(e,n){if(e){if(void 0!==n.logLevels[e])return n.logLevels[e];if(-1!==e.indexOf("."))return r(e.substring(0,e.lastIndexOf(".")),n)}return void 0!==n.logLevels["*"]?n.logLevels["*"]:t.LEVEL.TRACE}return n>t.LEVEL.OFF&&n<=r(e,o)}function f(n,o,r,i,a){function g(n){var o="undefined"!=typeof e,r=o&&n.length>=2&&"string"==typeof n[0]&&-1!==n[0].indexOf("%");if(r)try{var i=t.countSprintfHolders(n[0]);i>0&&(n[0]=e.apply(null,n),n.splice(1,i))}catch(a){n.unshift(a)}return n}var l=L(o,r,i,a),c=g([].slice.call(n));return[l].concat([].slice.call(c))}function L(t,o,r,i){var a="";if("undefined"!=typeof n)a=n().locale(r).format(o);else{var g=new Date,l=(new Date).toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0];a=g.getDate()+"-"+(g.getMonth()+1)+"-"+g.getFullYear()+" "+l}return"undefined"!=typeof e?e(i,a,t):a+"::["+t+"]> "}return a.logLevels=a.logLevels||[],function(){if(u(i,r,a)){var e=f(arguments,i,g,l,c);return o.apply(null,e),e}return null}},t.countSprintfHolders=function(n){function t(e){return function(){r=Math.max(r,e)}}var o=/\x25\([a-zA-Z0-9_]+\)[b-fijosuxX]/.test(n);if(o)return 1;var r=0;return e(n,t(1),t(2),t(3),t(4),t(5),t(6),t(7),t(8),t(9),t(10)),r}};if("undefined"!=typeof n)n.exports.LoggingEnhancer=e;else if("undefined"!=typeof t)t.LoggingEnhancer=e;else{if("undefined"==typeof window)throw new Error("unable to expose LoggingEnhancer: no module, exports object and no global window detected");window.loggingEnhancer=new e(window.sprintf,window.moment)}}()},{}]},{},[1]); \ No newline at end of file diff --git a/package.json b/package.json index 1c40517..45df345 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-logger", - "version": "1.0.2", + "version": "1.0.4", "description": "> Enhance $log for better logging, including patterns and level management", "main": "angular-logger.min.js", "scripts": { diff --git a/src/angular-logger.js b/src/angular-logger.js index cd318ed..4494e6a 100644 --- a/src/angular-logger.js +++ b/src/angular-logger.js @@ -60,6 +60,7 @@ var LoggingEnhancer = require('../bower_components/better-logging-base/dist/logg config(['$provide', 'logEnhancerProvider', function ($provide, p) { $provide.decorator('$log', ['$delegate', function ($delegate) { + $delegate.logLevels = p.logLevels; // copy the initial loglevel config return { // keep original methods, otherwise the enhanced functions on .getInstance() will have a double (global context) prefix $$orig$log: angular.extend({}, $delegate),