Skip to content

Commit 99467c7

Browse files
committed
Added toastr to logger
1 parent 72d7489 commit 99467c7

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

bower.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
},
2020
"dependencies": {
2121
"angular": "~1.4.0",
22+
"angular-animate": "~1.4.0",
2223
"angular-bootstrap": "~0.13.0",
2324
"angular-sanitize": "~1.4.0",
25+
"angular-toastr": "~1.4.1",
2426
"angular-ui-router": "~0.2.15",
2527
"bootstrap-sass": "~3.3.4",
2628
"lodash": "~3.9.3"

karma.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ module.exports = function (config) {
1515
// list of files / patterns to load in the browser
1616
files: [
1717
'bower_components/angular/angular.js',
18+
'bower_components/angular-animate/angular-animate.js',
1819
'bower_components/angular-bootstrap/ui-bootstrap.js',
1920
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
2021
'bower_components/angular-sanitize/angular-sanitize.js',
22+
'bower_components/angular-toastr/dist/angular-toastr.js',
23+
'bower_components/angular-toastr/dist/angular-toastr.tpls.js',
2124
'bower_components/angular-ui-router/release/angular-ui-router.js',
2225
'bower_components/angular-mocks/angular-mocks.js',
2326
'bower_components/bardjs/dist/bard.js',

src/components/dashboard/dashboard.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
activate();
3434

3535
function activate() {
36-
logger.info('Activated Dashboard View');
36+
logger.log('Activated Dashboard View');
3737
}
3838
}
3939

src/core/core.module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
'use strict';
33

44
angular.module('app.core', [
5-
// Angular modules
6-
'ngSanitize',
5+
// Angular modules (ngAnimate 1.4.x is not compatible with ui.bootstrap 0.13.0)
6+
/* 'ngAnimate', */ 'ngSanitize',
77

88
// Our reusable framework
99
'fw.exception', 'fw.logger',
1010

1111
// 3rd Party modules
12-
'ui.bootstrap', 'ui.router'
12+
'toastr', 'ui.bootstrap', 'ui.router'
1313
]);
1414
})();

src/framework/exception/exception-handler.provider.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@
4040
$provide.decorator('$exceptionHandler', extendExceptionHandler);
4141
}
4242

43-
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', 'logger'];
43+
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', '$injector'];
4444

4545
/**
4646
* Extend the $exceptionHandler service to log via the logger service.
4747
* @param {Object} $delegate
4848
* @param {Object} exceptionHandler
49-
* @param {Object} logger
49+
* @param {Object} $injector
5050
* @return {Function} the decorated $exceptionHandler service
5151
*/
52-
function extendExceptionHandler($delegate, exceptionHandler, logger) {
52+
function extendExceptionHandler($delegate, exceptionHandler, $injector) {
5353
return function(exception, cause) {
54+
// Need to load logger at runtime to avoid circular dependency with toastr
55+
var logger = $injector.get('logger');
5456
var appErrorPrefix = exceptionHandler.config.appErrorPrefix || '';
5557
var errorData = {exception: exception, cause: cause};
5658
exception.message = appErrorPrefix + exception.message;

src/framework/logger/logger.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
.module('fw.logger')
66
.factory('logger', logger);
77

8-
logger.$inject = ['$log'];
8+
logger.$inject = ['$log', 'toastr'];
99

1010
/* @ngInject */
11-
function logger($log) {
11+
function logger($log, toastr) {
1212
var service = {
1313
log : log,
1414
info : info,
@@ -25,14 +25,17 @@
2525
}
2626

2727
function info(message) {
28+
toastr.info(message, 'Information');
2829
$log.info('info: ' + message);
2930
}
3031

3132
function warn(message) {
33+
toastr.warning(message, 'Warning');
3234
$log.warn('warn: ' + message);
3335
}
3436

3537
function error(message) {
38+
toastr.error(message, 'Error');
3639
$log.error('error: ' + message);
3740
}
3841

src/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400' rel='stylesheet' type='text/css'>
2020

2121
<!-- build:css styles/lib.css -->
22+
<link href="/bower_components/angular-toastr/dist/angular-toastr.css" rel="stylesheet" type="text/css">
2223
<!-- endbuild -->
2324

2425
<!-- build:css styles/app.css-->
@@ -34,9 +35,12 @@
3435

3536
<!-- build:js js/lib.js -->
3637
<script src="/bower_components/angular/angular.js"></script>
38+
<script src="/bower_components/angular-animate/angular-animate.js"></script>
3739
<script src="/bower_components/angular-bootstrap/ui-bootstrap.js"></script>
3840
<script src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
3941
<script src="/bower_components/angular-sanitize/angular-sanitize.js"></script>
42+
<script src="/bower_components/angular-toastr/dist/angular-toastr.js"></script>
43+
<script src="/bower_components/angular-toastr/dist/angular-toastr.tpls.js"></script>
4044
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
4145
<script src="/bower_components/lodash/lodash.js"></script>
4246
<!-- endbuild -->

0 commit comments

Comments
 (0)