11/**
2- * Log Unobtrusive Extension v0.0.13
2+ * Log Unobtrusive Extension v0.0.14-0+sha.4893751
33 *
44 * Used within AngularJS to enhance functionality within the AngularJS $log service.
55 *
@@ -30,6 +30,12 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
3030 */
3131 var enableGlobally = false ;
3232
33+ /**
34+ * Used to enable template engine globally
35+ * @type {boolean }
36+ */
37+ var enableTemplatesGlobally = false ;
38+
3339 /**
3440 * Used to enable quiet logger enabling.
3541 * When this feature is enable the config message is not shown
@@ -140,7 +146,7 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
140146 * @returns {String } - returns a string with the type of the evaluated operand
141147 */
142148 var itypeof = function ( val ) {
143- return Object . prototype . toString . call ( val ) . replace ( / ( \[ | o b j e c t | \s | \ ]) / g, "" ) . toLowerCase ( ) ;
149+ return Object . prototype . toString . call ( val ) . replace ( / ( \[ | o b j e c t | \s | ] ) / g, "" ) . toLowerCase ( ) ;
144150 } ;
145151
146152 /**
@@ -314,7 +320,7 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
314320 if ( criteria1 || criteria2 ) {
315321 return Array . prototype . slice . call ( arguments ) ;
316322 }
317- pattern = itypeof ( pattern ) === 'regexp' ? pattern : / \{ ( [ ^ \{ \ }] * ) \ }/ g;
323+ pattern = itypeof ( pattern ) === 'regexp' ? pattern : / \{ ( [ ^ { } ] * ) } / g;
318324
319325 return template . replace ( pattern , function ( patternToReplace , replacementKey ) {
320326 var replacementKeyList = replacementKey . split ( '.' ) ,
@@ -486,6 +492,14 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
486492 * @returns {Function } - returns function with specific rules for a log metod
487493 */
488494 var prepareLogFn = function ( logFn , className , override , useOverride , useTemplate , colorCss ) {
495+
496+ var activateTemplates = useTemplate ;
497+
498+ // override template activation if templateGlobally is true
499+ if ( ! useTemplate && enableTemplatesGlobally ) {
500+ activateTemplates = enableTemplatesGlobally ;
501+ }
502+
489503 var enhancedLogFn = function ( ) {
490504 var activate = ( useOverride ) ? activateLogs ( enabled , override ) : enabled ;
491505 if ( activate ) {
@@ -496,7 +510,7 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
496510 args = filterSensitiveValues ( args ) ;
497511 }
498512 var prefix = getLogPrefix ( className ) ;
499- if ( validateTemplateInputs ( useTemplate , args ) ) {
513+ if ( validateTemplateInputs ( activateTemplates , args ) ) {
500514 var data = ( supplant . apply ( null , args ) ) ;
501515 data = ( itypeof ( data ) === 'string' ) ? [ data ] : data ;
502516 args = data ;
@@ -638,6 +652,14 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
638652 enabledQuietly = isBoolean ( verbose ) ? verbose : false ;
639653 } ;
640654
655+ /**
656+ * Used externally to enable/disable template engine
657+ * @param {boolean } flag - flag that sets whether template engine is enabled/disabled
658+ */
659+ var useTemplates = function ( flag ) {
660+ enableTemplatesGlobally = isBoolean ( flag ) ? flag : false ;
661+ } ;
662+
641663 /**
642664 * Configure which log functions can be exposed at runtime
643665 * @param {*[] } arrMethods - list of methods that can be used
@@ -736,15 +758,16 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
736758 this . $get = function ( ) {
737759 return {
738760 name : 'Log Unobtrusive Extension' ,
739- version : '0.0.13 ' ,
761+ version : '0.0.14-0+sha.4893751 ' ,
740762 enableLogging : enableLogging ,
741763 restrictLogMethods : restrictLogMethods ,
742764 overrideLogPrefix : overrideLogPrefix ,
743765 disableDefaultColors : disableDefaultColors ,
744766 setLogMethodColor : setLogMethodColor ,
745767 overrideLogMethodColors : overrideLogMethodColors ,
746768 useDefaultLogPrefix : useDefaultLogPrefix ,
747- configureLogFilters : configureLogFilters
769+ configureLogFilters : configureLogFilters ,
770+ useTemplates : useTemplates
748771 } ;
749772 } ;
750773
@@ -757,4 +780,5 @@ angular.module("log.ex.uo", []).provider('logEx', ['$provide', function($provide
757780 this . overrideLogMethodColors = overrideLogMethodColors ;
758781 this . useDefaultLogPrefix = useDefaultLogPrefix ;
759782 this . configureLogFilters = configureLogFilters ;
783+ this . useTemplates = useTemplates ;
760784} ] ) ;
0 commit comments