debugging log

Hello there,

I’m trying to debug my watch app "kronosGhost", I've built for my device, an EDGE 520 and unchecked build release and include debug XML.

I've put kronosGhost.prg and KronosGhost.debug.xml in my APPS folder. Then I've run it and it seems to freeze, by that I mean that I cannot exit the app  (e.g. by pressing the ESC key). (In the simulator everything is fine.)
To debug I've created KronosGhost.txt and CIQ_LOG.txt in the APPS/LOGS folder
But those files remain empty.

  • If you build a non release version, no need to copy the .xml file to the device.  Are your println calls showing in the KronosGhost.txt file?

    what does your delegate look like (post the code) as far as your handling of KEY_ESC.  Are you also doing onBack()?  what are you returning from the handler?

  • No KronosGhost.txt  always remains empty, no println() data.

    Here is my delegate:

    class BaseInputDelegate extends WatchUi.BehaviorDelegate
    {
    
        function initialize() {
            BehaviorDelegate.initialize();
        }
    
        function onMenu() {
            return true;
        }
        
        
        function onKeyPressed(keyEvent){
            if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_START ) {
                if( ( session == null ) || ( session.isRecording() == false ) ) {
                    session = ActivityRecording.createSession({:name=>"Kronos", :sport=>ActivityRecording.SPORT_CYCLING});
                    session.start();
                    WatchUi.requestUpdate();
                }
                else if( ( session != null ) && session.isRecording() ) {
                    session.stop();
                    session.save();
                    session = null;
                    WatchUi.requestUpdate();
                }
            }else if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_ESC){
            		Sys.exit();
            }
        	
        } 
    
    }
    

  • You got a couple things going on here.  When you have something like onKey(), you always want to return true of false, indicating if you handled the event or if you want the system default.

    In the case of onKey and KEY_START, you want to return true.  In the case of KEY_ESC, false, as you want the default action - exiting the app. (you shouldn't need System.exit()).  If you fall thru onKey, you also want to return false;

    But there's more.  For KEY_ESC, you may want to return true if you are recording, so that the app doesn't exit without closing out the session, or always close the session for KEY_ESC if one exists. 

  • Thanks for your reply, now it's cleaner, I've that:

    class BaseInputDelegate extends WatchUi.BehaviorDelegate
    {
    
        function initialize() {
            BehaviorDelegate.initialize();
        }
    
        function onMenu() {
            return true;
        }
        
        
        function onKeyPressed(keyEvent){
            if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_START ) {
                if( ( session == null ) || ( session.isRecording() == false ) ) {
                    session = ActivityRecording.createSession({:name=>"Kronos", :sport=>ActivityRecording.SPORT_CYCLING});
                    session.start();
                    WatchUi.requestUpdate();
                }
                else if( ( session != null ) && session.isRecording() ) {
                    session.stop();
                    session.save();
                    session = null;
                    WatchUi.requestUpdate();
                }
                return true;
            }else if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_ESC){
            		if( ( session != null ) && session.isRecording() ){
    	     		    session.stop();
    	                session.save();
    	                session = null;
                    }
            		return false;
            }   	
    	    return true;
        } 
    
    }

    But I still don't succeed in debugging my app

  • Maybe it's because I'm on my first cup of coffee, but I don't see any println calls in your code.  That's what gets written to your app's log file.

  • Oops, in fact, I've this Appbase:

    using Toybox.Application as App;
    using Toybox.System as Sys;
    using Toybox.WatchUi as Ui;
    using Toybox.Time;
    using Toybox.UserProfile;
    using Toybox.PersistedContent;
    using Toybox.System;
    using Toybox.Communications as Comm;
    using Toybox.Position;
    
    
    class KronosGhostWApp extends App.AppBase {
    	var Kview;
    
        function initialize() {
            AppBase.initialize();
    		Sys.println("AppBase initialize");
          }
    
        // onStart() is called on application start up
        function onStart(state) { 
    	    System.println("start");
            Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
        	
        }
    
        // onStop() is called when your application is exiting
        function onStop(state) {
    		System.println("stop");
    		Kview.stopRecording();
    		Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
        }
    
    
        function onPosition(info) {
        }
    
        //! Return the initial view of your application here
        function getInitialView() {
        	System.println("getInitialView");
        	Kview = new KronosGhostWView();
            return [ Kview, new BaseInputDelegate()];
        }
    
    }
    

    And in this class there is some println

  • Are you sure the name of your prg and txt file names are the same -including case?  MyApp.prg would use MyApp.txt if it was pre-created and not myapp.txt if it was pre-created on many devices for example. and the txt file must be in apps\logs

  • I'm stumped, as I use this very often and never had an issue.

  • I've found what is the problem and it is annoying.
    The fact is I need, like a DataField app, refresh the screen at least every seconds so, as a noob, have done a  WatchUi.requestUpdate(); at the end of onUpdate. This works with the simulator but not with my edge 520.