-
Notifications
You must be signed in to change notification settings - Fork 11
/
demo.html
40 lines (38 loc) · 1.54 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="angular-ny-logger.js"></script>
</head>
<body>
Please open console to see the logging
<div id="app1" ng-controller="ExampleController"></div>
<div id="app2" ng-controller="ExampleController"></div>
<script>
angular.module('AppWithLoggerOn', ['ny.logger'])
.config(['LoggerProvider', function(LoggerProvider) {
LoggerProvider.enabled(true);
}])
.controller('ExampleController', ['Logger', function(Logger) {
var logger = Logger.getInstance('AppWithLoggerOn');
logger.log('This is a log');
logger.warn('warn', 'This is a warn');
logger.error('This is a {0} error! {1}', [ 'big', 'just kidding' ]);
logger.debug('debug', 'This is a debug for line {0}', [ 8 ]);
}]);
angular.bootstrap(document.getElementById('app1'), ['AppWithLoggerOn']);
angular.module('AppWithLoggerOff', ['ny.logger'])
.config(['LoggerProvider', function(LoggerProvider) {
LoggerProvider.enabled(false);
}])
.controller('ExampleController', ['Logger', function(Logger) {
var logger = Logger.getInstance('AppWithLoggerOff');
logger.log('This is a log');
logger.warn('warn', 'This is a warn');
logger.error('This is a {0} error! {1}', [ 'big', 'just kidding' ]);
logger.debug('debug', 'This is a debug for line {0}', [ 8 ]);
}]);
angular.bootstrap(document.getElementById('app2'), ['AppWithLoggerOff']);
</script>
</body>
</html>