better-js-logging / angular-logger

angular-logger2 released! Enhance $log for better logging, including patterns and level management
https://github.com/better-js-logging/angular-logger2
MIT License
46 stars 10 forks source link

Error formating numbers #21

Open Toub opened 8 years ago

Toub commented 8 years ago

Looks like the numbers formatter always fails when using decimals. It should never fail, even if the decimal is not provided.

   $log.getInstance('main').info('===> This works: "%s"', "string text");
   $log.getInstance('main').info('===> This fails: "%d"', 10);

Stack trace:

"June 19, 2016 3:44 PM::[main]> " "Error: [sprintf] expecting number but found undefined
[4]</</sprintf.format@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:3893:1
sprintf@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:3860:16
[2]</</LoggingEnhancer/self.countSprintfHolders@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:215:1
maybeApplySprintf@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:158:31
enhanceLogline@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:149:25
[2]</</LoggingEnhancer/this.enhanceLogging/<@http://localhost:3000/bower_components/angular-logger/dist/angular-logger.js:122:30
[...]
" "===> This fails: "%d"" 10
bbottema commented 8 years ago

@Toub angular-logger uses whatever version of sprintf you are currently using. It seems an issue with sprintf. Can you try with some other versions as well?

On a sidenote, I also released a new patch version, 1.3.2.

david-hollifield commented 4 years ago

I know this is a long time ago, but I'm getting the same error.

This fails: this.$log.debug("cropAspectRatio => %f", this.cropAspectRatio); This works: this.$log.debug(sprintf("cropAspectRatio => %f", this.cropAspectRatio));

i'm no sure what's going on. I'm using 1.3.2 of angular-logger and 1.1.2 of sprintf-js