diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-06-27 09:52:06 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-06-27 09:52:06 -0400 |
| commit | 319d4cb6670729708c19ad50b0146d1bcb7b4719 (patch) | |
| tree | c61e9723a1fd217b1816c987bba66e470e73bf02 /www/js/LogCtrl.js | |
| parent | fdc42fae48db0fef5fbdc9ef51a27d219aea3a72 (diff) | |
Added ability to log key events to file and email (useful for release debugging)
Diffstat (limited to 'www/js/LogCtrl.js')
| -rw-r--r-- | www/js/LogCtrl.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js new file mode 100644 index 00000000..1ac903a7 --- /dev/null +++ b/www/js/LogCtrl.js @@ -0,0 +1,61 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + +angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer) { + $scope.openMenu = function () { + $ionicSideMenuDelegate.toggleLeft(); + }; + + + //-------------------------------------------------------------------------- + // Convenience function to send logs via email + //-------------------------------------------------------------------------- + $scope.sendEmail = function (logstring) { + if (window.cordova) { + // pass= password= should be replaced + //logstring = logstring.replace(/password=*?/g, 'password=xxxx' + $cordovaEmailComposer.isAvailable().then(function () { + var email = { + to: '', + subject: 'zmNinja Logs', + body: logstring, + isHtml: false + }; + $cordovaEmailComposer.open(email); + }, function () { + ZMDataModel.zmLog("Email plugin not found", "error"); + }); + } else { + console.log("Skipping email module as cordova does not exist"); + } + + }; + + //------------------------------------------------------------------------- + // Lets make sure we set screen dim properly as we enter + // The problem is we enter other states before we leave previous states + // from a callback perspective in ionic, so we really can't predictably + // reset power state on exit as if it is called after we enter another + // state, that effectively overwrites current view power management needs + //------------------------------------------------------------------------ + $scope.$on('$ionicView.enter', function () { + console.log("**VIEW ** Log Ctrl Entered"); + ZMDataModel.setAwake(false); + + $scope.zmLog = { + logString: "" + }; + $fileLogger.getLogfile().then(function (l) { + + $scope.zmLog.logString = l; + //console.log ("LOGS" + logstring); + }, + function (error) { + $scope.zmLog.logString = "Error getting log: " + JSON.stringify(error); + }); + + + }); + +}]); |
