diff --git a/build/browser/app.js b/build/browser/app.js
index 806df0db..1b3a6cdd 100644
--- a/build/browser/app.js
+++ b/build/browser/app.js
@@ -29,6 +29,7 @@ require('angular-ui-bootstrap');
require('./modules/selection-state');
require('./modules/drive-scanner');
require('./modules/image-writer');
+require('./modules/logger');
require('./modules/path');
var app = angular.module('ResinEtcher', [
@@ -38,10 +39,11 @@ var app = angular.module('ResinEtcher', [
'ResinEtcher.path',
'ResinEtcher.selection-state',
'ResinEtcher.drive-scanner',
- 'ResinEtcher.image-writer'
+ 'ResinEtcher.image-writer',
+ 'ResinEtcher.logger'
]);
-app.controller('AppController', function($q, DriveScannerService, SelectionStateService, ImageWriterService) {
+app.controller('AppController', function($q, DriveScannerService, SelectionStateService, ImageWriterService, LoggerService) {
'use strict';
var self = this;
@@ -50,7 +52,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.scanner = DriveScannerService;
this.restart = function() {
- console.debug('Restarting');
+ LoggerService.debug('Restarting');
this.selection.clear();
this.writer.reset();
this.scanner.start(2000).on('scan', function(drives) {
@@ -67,7 +69,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
// `angular.equals` is used instead of `_.isEqual` to
// cope with `$$hashKey`.
if (!angular.equals(self.selection.getDrive(), drive)) {
- console.debug('Autoselecting drive: ' + drive.device);
+ LoggerService.debug('Autoselecting drive: ' + drive.device);
self.selectDrive(drive);
}
@@ -84,13 +86,13 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.selectImage = function() {
return $q.when(dialog.selectImage()).then(function(image) {
self.selection.setImage(image);
- console.debug('Image selected: ' + image);
+ LoggerService.debug('Image selected: ' + image);
});
};
this.selectDrive = function(drive) {
self.selection.setDrive(drive);
- console.debug('Drive selected: ' + drive.device);
+ LoggerService.debug('Drive selected: ' + drive.device);
};
this.burn = function(image, drive) {
@@ -99,16 +101,16 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
// otherwise Windows throws EPERM
self.scanner.stop();
- console.debug('Burning ' + image + ' to ' + drive.device);
+ LoggerService.debug('Burning ' + image + ' to ' + drive.device);
return self.writer.burn(image, drive).then(function() {
- console.debug('Done!');
+ LoggerService.debug('Done!');
}).catch(dialog.showError);
};
this.open = shell.openExternal;
});
-},{"./modules/drive-scanner":2,"./modules/image-writer":3,"./modules/path":4,"./modules/selection-state":5,"angular":9,"angular-ui-bootstrap":6,"lodash":10}],2:[function(require,module,exports){
+},{"./modules/drive-scanner":2,"./modules/image-writer":3,"./modules/logger":4,"./modules/path":5,"./modules/selection-state":6,"angular":10,"angular-ui-bootstrap":7,"lodash":11}],2:[function(require,module,exports){
(function (__dirname){
/*
* Copyright 2016 Resin.io
@@ -304,7 +306,7 @@ driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshServ
});
}).call(this,"/lib/browser/modules")
-},{"angular":9,"events":undefined,"lodash":10,"path":undefined}],3:[function(require,module,exports){
+},{"angular":10,"events":undefined,"lodash":11,"path":undefined}],3:[function(require,module,exports){
(function (__dirname){
/*
* Copyright 2016 Resin.io
@@ -328,6 +330,7 @@ driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshServ
var angular = require('angular');
var remote = window.require('remote');
+require('./logger');
if (window.mocha) {
var writer = remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer'));
@@ -335,9 +338,11 @@ if (window.mocha) {
var writer = remote.require('./src/writer');
}
-var imageWriter = angular.module('ResinEtcher.image-writer', []);
+var imageWriter = angular.module('ResinEtcher.image-writer', [
+ 'ResinEtcher.logger'
+]);
-imageWriter.service('ImageWriterService', function($q, $timeout) {
+imageWriter.service('ImageWriterService', function($q, $timeout, LoggerService) {
'use strict';
var self = this;
@@ -388,7 +393,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) {
// Transform bytes to megabytes preserving only two decimal places
self.state.speed = Math.floor(state.speed / 1e+6 * 100) / 100 || 0;
- console.debug('Progress: ' + self.state.progress + '% at ' + self.state.speed + ' MB/s');
+ LoggerService.debug('Progress: ' + self.state.progress + '% at ' + self.state.speed + ' MB/s');
});
};
@@ -500,7 +505,51 @@ imageWriter.service('ImageWriterService', function($q, $timeout) {
});
}).call(this,"/lib/browser/modules")
-},{"angular":9,"path":undefined}],4:[function(require,module,exports){
+},{"./logger":4,"angular":10,"path":undefined}],4:[function(require,module,exports){
+/*
+ * Copyright 2016 Resin.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @module ResinEtcher.logger
+ */
+
+var angular = require('angular');
+var logger = angular.module('ResinEtcher.logger', []);
+
+logger.service('LoggerService', function() {
+ 'use strict';
+
+ /**
+ * @summary Print a debug log message
+ * @function
+ * @public
+ *
+ * @param {String} message - message
+ *
+ * @example
+ * LoggerService.debug('Hello World');
+ */
+ this.debug = function(message) {
+ console.debug(new Date() + ' ' + message);
+ };
+
+});
+
+
+},{"angular":10}],5:[function(require,module,exports){
/*
* Copyright 2016 Resin.io
*
@@ -543,7 +592,7 @@ pathModule.filter('basename', function() {
return path.basename;
});
-},{"angular":9,"path":undefined}],5:[function(require,module,exports){
+},{"angular":10,"path":undefined}],6:[function(require,module,exports){
/*
* Copyright 2016 Resin.io
*
@@ -683,11 +732,11 @@ selectionState.service('SelectionStateService', function() {
});
-},{"angular":9}],6:[function(require,module,exports){
+},{"angular":10}],7:[function(require,module,exports){
require('./ui-bootstrap-tpls');
module.exports = 'ui.bootstrap';
-},{"./ui-bootstrap-tpls":7}],7:[function(require,module,exports){
+},{"./ui-bootstrap-tpls":8}],8:[function(require,module,exports){
/*
* angular-ui-bootstrap
* http://angular-ui.github.io/bootstrap/
@@ -9191,7 +9240,7 @@ angular.module("template/typeahead/typeahead-popup.html", []).run(["$templateCac
"");
}]);
!angular.$$csp() && angular.element(document).find('head').prepend('');
-},{}],8:[function(require,module,exports){
+},{}],9:[function(require,module,exports){
/**
* @license AngularJS v1.4.8
* (c) 2010-2015 Google, Inc. http://angularjs.org
@@ -38210,11 +38259,11 @@ $provide.value("$locale", {
})(window, document);
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend('');
-},{}],9:[function(require,module,exports){
+},{}],10:[function(require,module,exports){
require('./angular');
module.exports = angular;
-},{"./angular":8}],10:[function(require,module,exports){
+},{"./angular":9}],11:[function(require,module,exports){
(function (global){
/**
* @license
diff --git a/lib/browser/app.js b/lib/browser/app.js
index d0450ef6..2bddff80 100644
--- a/lib/browser/app.js
+++ b/lib/browser/app.js
@@ -28,6 +28,7 @@ require('angular-ui-bootstrap');
require('./modules/selection-state');
require('./modules/drive-scanner');
require('./modules/image-writer');
+require('./modules/logger');
require('./modules/path');
var app = angular.module('ResinEtcher', [
@@ -37,10 +38,11 @@ var app = angular.module('ResinEtcher', [
'ResinEtcher.path',
'ResinEtcher.selection-state',
'ResinEtcher.drive-scanner',
- 'ResinEtcher.image-writer'
+ 'ResinEtcher.image-writer',
+ 'ResinEtcher.logger'
]);
-app.controller('AppController', function($q, DriveScannerService, SelectionStateService, ImageWriterService) {
+app.controller('AppController', function($q, DriveScannerService, SelectionStateService, ImageWriterService, LoggerService) {
'use strict';
var self = this;
@@ -49,7 +51,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.scanner = DriveScannerService;
this.restart = function() {
- console.debug('Restarting');
+ LoggerService.debug('Restarting');
this.selection.clear();
this.writer.reset();
this.scanner.start(2000).on('scan', function(drives) {
@@ -66,7 +68,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
// `angular.equals` is used instead of `_.isEqual` to
// cope with `$$hashKey`.
if (!angular.equals(self.selection.getDrive(), drive)) {
- console.debug('Autoselecting drive: ' + drive.device);
+ LoggerService.debug('Autoselecting drive: ' + drive.device);
self.selectDrive(drive);
}
@@ -83,13 +85,13 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.selectImage = function() {
return $q.when(dialog.selectImage()).then(function(image) {
self.selection.setImage(image);
- console.debug('Image selected: ' + image);
+ LoggerService.debug('Image selected: ' + image);
});
};
this.selectDrive = function(drive) {
self.selection.setDrive(drive);
- console.debug('Drive selected: ' + drive.device);
+ LoggerService.debug('Drive selected: ' + drive.device);
};
this.burn = function(image, drive) {
@@ -98,9 +100,9 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
// otherwise Windows throws EPERM
self.scanner.stop();
- console.debug('Burning ' + image + ' to ' + drive.device);
+ LoggerService.debug('Burning ' + image + ' to ' + drive.device);
return self.writer.burn(image, drive).then(function() {
- console.debug('Done!');
+ LoggerService.debug('Done!');
}).catch(dialog.showError);
};
diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js
index 8c802e83..63de1433 100644
--- a/lib/browser/modules/image-writer.js
+++ b/lib/browser/modules/image-writer.js
@@ -20,6 +20,7 @@
var angular = require('angular');
var remote = window.require('remote');
+require('./logger');
if (window.mocha) {
var writer = remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer'));
@@ -27,9 +28,11 @@ if (window.mocha) {
var writer = remote.require('./src/writer');
}
-var imageWriter = angular.module('ResinEtcher.image-writer', []);
+var imageWriter = angular.module('ResinEtcher.image-writer', [
+ 'ResinEtcher.logger'
+]);
-imageWriter.service('ImageWriterService', function($q, $timeout) {
+imageWriter.service('ImageWriterService', function($q, $timeout, LoggerService) {
'use strict';
var self = this;
@@ -80,7 +83,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) {
// Transform bytes to megabytes preserving only two decimal places
self.state.speed = Math.floor(state.speed / 1e+6 * 100) / 100 || 0;
- console.debug('Progress: ' + self.state.progress + '% at ' + self.state.speed + ' MB/s');
+ LoggerService.debug('Progress: ' + self.state.progress + '% at ' + self.state.speed + ' MB/s');
});
};
diff --git a/lib/browser/modules/logger.js b/lib/browser/modules/logger.js
new file mode 100644
index 00000000..8e92f46f
--- /dev/null
+++ b/lib/browser/modules/logger.js
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 Resin.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @module ResinEtcher.logger
+ */
+
+var angular = require('angular');
+var logger = angular.module('ResinEtcher.logger', []);
+
+logger.service('LoggerService', function() {
+ 'use strict';
+
+ /**
+ * @summary Print a debug log message
+ * @function
+ * @public
+ *
+ * @param {String} message - message
+ *
+ * @example
+ * LoggerService.debug('Hello World');
+ */
+ this.debug = function(message) {
+ console.debug(new Date() + ' ' + message);
+ };
+
+});
+