aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/log.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ng/log.js')
-rw-r--r--src/ng/log.js46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/ng/log.js b/src/ng/log.js
index 1b552da8..2a58d442 100644
--- a/src/ng/log.js
+++ b/src/ng/log.js
@@ -33,7 +33,33 @@
</example>
*/
+/**
+ * @ngdoc object
+ * @name ng.$logProvider
+ * @description
+ * Use the `$logProvider` to configure how the application logs messages
+ */
function $LogProvider(){
+ var debug = true,
+ self = this;
+
+ /**
+ * @ngdoc property
+ * @name ng.$logProvider#debugEnabled
+ * @methodOf ng.$logProvider
+ * @description
+ * @param {string=} flag enable or disable debug level messages
+ * @returns {*} current value if used as getter or itself (chaining) if used as setter
+ */
+ this.debugEnabled = function(flag) {
+ if (isDefined(flag)) {
+ debug = flag;
+ return this;
+ } else {
+ return debug;
+ }
+ };
+
this.$get = ['$window', function($window){
return {
/**
@@ -74,7 +100,25 @@ function $LogProvider(){
* @description
* Write an error message
*/
- error: consoleLog('error')
+ error: consoleLog('error'),
+
+ /**
+ * @ngdoc method
+ * @name ng.$log#debug
+ * @methodOf ng.$log
+ *
+ * @description
+ * Write a debug message
+ */
+ debug: (function () {
+ var fn = consoleLog('debug');
+
+ return function() {
+ if (debug) {
+ fn.apply(self, arguments);
+ }
+ }
+ }())
};
function formatError(arg) {