CRSBY.

  • Contact
You are here: Home / News / Using Angular’s $log provider

Using Angular’s $log provider

April 15, 2014 by jccrosby 1 Comment

The AngularJS $logProvider

Logging and debugging is a daily occurrence when developing JavaScript based applications. AngularJS provides a simple, effective way to enable logging in your applications – the $logProvider. $logProvider is a used to enable logging and the $log object is used to log within your applications objects.

Enabling

Enabling the $logProvider is as simple as injecting the $log object into your object and then calling $log.debug(); to send logs to the console.
Example:

Turning off logging

You can disable logging (AngularJS 1.1.2+) by calling
$logProvider.debugEnabled(false);
Example:

Extending

AngularJS provides a mechanisms to extend the built in $logProvider, $provider.decorator(). An example will get the point across much more quickly than me trying to explain it all.
Example:

Basically we intercept the call using decorate so we can add on the features and functionality we need to the $log.debug() call.

AngualrJS version 1.2.16 was used as a basis for this article.
Thanks to Burleson Thomas and this post for the extension example.

Filed Under: News Tagged With: angularjs, javascript

Comments

  1. jccrosby says

    July 8, 2014 at 5:24 am

    Testing disqus

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

My Thoughts on Backbone vs. Angular?

In the past few years I’ve gotten very familiar with JavaScript and many of the libraries … More

Using Angular’s $log provider

The AngularJS $logProvider Logging and debugging is a daily occurrence when developing … More

AngularJS: Getting Started

Getting Started AngularJS is a JavaScript framework that provides lots of solutions to … More

AngularJS, what is it?

AngularJS, Simply Put AngularJS is a JavaScript framework. It provides an Application … More

AngularJS: Simple Tabs

Because of projects and personal interest, I've been working with AngularJS lately. A … More

Our Location

We love living and working in Rockford Michigan!

Contact Us

Need help with your site? Fill out the contact form and let us know what you need.

Copyright © 2019 · crsby.com · John Crosby