Show / Hide Table of Contents
-
ng
- function
- angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement
- angular.bind
- angular.bootstrap
- angular.copy
- angular.element
- angular.equals
- angular.errorHandlingConfig
- angular.extend
- angular.forEach
- angular.fromJson
- angular.identity
- angular.injector
- angular.isArray
- angular.isDate
- angular.isDefined
- angular.isElement
- angular.isFunction
- angular.isNumber
- angular.isObject
- angular.isString
- angular.isUndefined
- angular.merge
- angular.module
- angular.noop
- angular.reloadWithDebugInfo
- angular.toJson
- directive
- a
- form
- input
- input[checkbox]
- input[date]
- input[datetime-local]
- input[email]
- input[month]
- input[number]
- input[radio]
- input[range]
- input[text]
- input[time]
- input[url]
- input[week]
- ngApp
- ngBind
- ngBindHtml
- ngBindTemplate
- ngBlur
- ngChange
- ngChecked
- ngClass
- ngClassEven
- ngClassOdd
- ngClick
- ngCloak
- ngController
- ngCopy
- ngCsp
- ngCut
- ngDblclick
- ngDisabled
- ngFocus
- ngForm
- ngHide
- ngHref
- ngIf
- ngInclude
- ngInit
- ngJq
- ngKeydown
- ngKeypress
- ngKeyup
- ngList
- ngMaxlength
- ngMinlength
- ngModel
- ngModelOptions
- ngMousedown
- ngMouseenter
- ngMouseleave
- ngMousemove
- ngMouseover
- ngMouseup
- ngNonBindable
- ngOn
- ngOpen
- ngOptions
- ngPaste
- ngPattern
- ngPluralize
- ngProp
- ngReadonly
- ngRef
- ngRepeat
- ngRequired
- ngSelected
- ngShow
- ngSrc
- ngSrcset
- ngStyle
- ngSubmit
- ngSwitch
- ngTransclude
- ngValue
- script
- select
- textarea
- object
- angular.version
- type
- $cacheFactory.Cache
- $compile.directive.Attributes
- $rootScope.Scope
- ModelOptions
- angular.Module
- form.FormController
- ngModel.NgModelController
- select.SelectController
- provider
- $anchorScrollProvider
- $animateProvider
- $compileProvider
- $controllerProvider
- $filterProvider
- $httpProvider
- $interpolateProvider
- $locationProvider
- $logProvider
- $parseProvider
- $qProvider
- $rootScopeProvider
- $sceDelegateProvider
- $sceProvider
- $templateRequestProvider
- service
- $anchorScroll
- $animate
- $animateCss
- $cacheFactory
- $compile
- $controller
- $document
- $exceptionHandler
- $filter
- $http
- $httpBackend
- $httpParamSerializer
- $httpParamSerializerJQLike
- $interpolate
- $interval
- $jsonpCallbacks
- $locale
- $location
- $log
- $parse
- $q
- $rootElement
- $rootScope
- $sce
- $sceDelegate
- $templateCache
- $templateRequest
- $timeout
- $window
- $xhrFactory
- filter
- currency
- date
- filter
- json
- limitTo
- lowercase
- number
- orderBy
- uppercase
- auto
- ngAnimate
- ngAria
- ngComponentRouter
- ngCookies
-
ngMessageFormat
- ngMessages
-
ngMock
- object
- angular.mock
- service
- $animate
- $componentController
- $controller
- $exceptionHandler
- $flushPendingTasks
- $httpBackend
- $interval
- $log
- $timeout
- $verifyNoPendingTasks
- provider
- $exceptionHandlerProvider
- type
- $rootScope.Scope
- angular.mock.TzDate
- function
- angular.mock.dump
- angular.mock.inject
- angular.mock.module
- angular.mock.module.sharedInjector
- browserTrigger
- ngMockE2E
-
ngParseExt
- ngResource
- ngRoute
- ngSanitize
- ngTouch
Loading …
There was an error loading this resource. Please try again later.
Improve this Doc
View Source
$log
- - $logProvider
- - service in module ng
Overview
Simple service for logging. Default implementation safely writes the message into the browser's console (if present).
The main purpose of this service is to simplify debugging and troubleshooting.
To reveal the location of the calls to $log
in the JavaScript console,
you can "blackbox" the AngularJS source in your browser:
Mozilla description of blackboxing. Chrome description of blackboxing.
Note: Not all browsers support blackboxing.
The default is to log debug
messages. You can use
ng.$logProvider#debugEnabled to change this.
Dependencies
Methods
-
log();
Write a log message
-
info();
Write an information message
-
warn();
Write a warning message
-
error();
Write an error message
-
debug();
Write a debug message
Example
angular.module('logExample', [])
.controller('LogController', ['$scope', '$log', function($scope, $log) {
$scope.$log = $log;
$scope.message = 'Hello World!';
}]);
<div ng-controller="LogController">
<p>Reload this page with open console, enter text and hit the log button...</p>
<label>Message:
<input type="text" ng-model="message" /></label>
<button ng-click="$log.log(message)">log</button>
<button ng-click="$log.warn(message)">warn</button>
<button ng-click="$log.info(message)">info</button>
<button ng-click="$log.error(message)">error</button>
<button ng-click="$log.debug(message)">debug</button>
</div>