javascript - WinJS appendTextAsync producing scheduler errors -


im trying implement logger in uwp app (windows 10) following code in both this , this answers. i'm afraid in both cases end getting scheduler (winjs.utilities.scheduler) errors @ random times (couldn't establish pattern). main problem the application freezes sometimes , suspect due log implementation because final line reads transitioning job (1) from: running to: blocked when happens.

i messages like

transitioning job (1) from: blocked_waiting to: cooperative_yield transitioning job (1) from: cooperative_yield to: scheduled 

in middle of execution, varying states.

initialization method

    this.init = function () {         let logger = new winjs.promise(function (complete) {             let = new date();             let logfilename = `log-${now.getdate()}-${now.getmonth() + 1}-${now.getfullyear()}.log`;              localfolder                 .createfolderasync("logs", windows.storage.creationcollisionoption.openifexists)                 .then(function (logsfolder) {                     logsfolder                         .createfileasync(logfilename, windows.storage.creationcollisionoption.openifexists)                         .done(function (file) {                             complete(file);                         });                 });         })          let logaction = function (message) {             logger.then(function (file) {                 windows.storage.fileio.appendtextasync(file, message + "\r\n");             });         }          winjs.utilities.startlog({ action: logaction });          return logger;     } 

log method

    this.log = function (message, messagetype) {         messagetype = messagetype || logmessagetype.info;          let = new date();         let timestamp = `${now.getdate()}/${now.getmonth() + 1}/${now.getfullyear()} ${now.gethours()}:${("0" + now.getminutes()).slice(-2)}:${now.getseconds()}`;          let typestr;          switch (messagetype) {             case logmessagetype.info:                 typestr = "info";                 break;             case logmessagetype.warning:                 typestr = "warning";                 break;             case logmessagetype.error:                 typestr = "error";                 break;         }          winjs && winjs.log(`[${timestamp}] [${typestr}] ${message}`);     } 

utility methods

    this.info = function (message) {         self.log(message, logmessagetype.info);     }      this.warning = function (message) {         self.log(message, logmessagetype.warning);     }      this.error = function (message) {         self.log(message, logmessagetype.error);     } 

simplified app.onactivated event (please read this comment happens think)

app.onactivated = function (args) {      system.ready.then(function modulesloaded() {         managers.logmanager             .init()             .then(function () {                 return self.settingsmanager.loadsettings();             })     });      args.setpromise(winjs.ui.processall());     applicationview.preferredlaunchwindowingmode = applicationviewwindowingmode.fullscreen;  }; 

i've tested application long time using console.log (in logaction) instead , seems had no problems.

i have no clue , non-existent documentation doesn't help.

regards.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -