lwhiteley / AngularLogExtender

AngularLogExtender is an AngularJS module that extends the Angular $log functionality. It uses the native $decorator to push the $log pass its capabilities and provide new functionality such as configuring the $log for different environments such as production and development
MIT License
40 stars 8 forks source link

Performance Improvement #17

Closed ferronrsmith closed 9 years ago

ferronrsmith commented 10 years ago

Performance To improve the performance of the debug, it is a good idea to surround your logging statements with appropriate isXXXEnabled() methods to evaluate before logging if the required logging level is enabled:

  if( myLogger.isDebugEnabled()) {
    myLogger.debug(...);
  }

If debug is disabled, it is much faster to evaluate only if it is disabled than constructing a possible complex message before finding debug level disabled. But this makes only sense when the messages are a little bit more complex than just log a simple string. Otherwise the sources are blown up too much with condition statements which is not much readable.

ferronrsmith commented 10 years ago

Should be added to the documentation for users to know.