Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 25

Thread: Request: Add Note to Debug Log

  1. #11
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    Thanks, it's been helpful to just talk about it. I think I'd want to restrict the ash function to strings, on the grounds that scripters can do their own type conversions in ash.

    testing updateDebugLog() when debug is off:
    in either case does nothing. It returns void, so the ash version will need to check isDebugging() itself. That's fine.

    testing DebugNoteMenuItem (my menu item) when debug is off:
    If no log file, create debug log file, append header and note, then turn debugging back off.
    If existing log file, append header and note to existing debug file, then turn debugging back off.

    I want to keep it off (on the principle of "do exactly what you're told". Also to save me changing the menu item

    However, I do want to have the ability to set the Start/Stop Debug item in cases where ash or the gCLI has toggled debug, so I have to figure out how to change a menu item in response to a different command. That should be fun.

    I'll be back when I've got further or stuck.

  2. #12
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    so I have to figure out how to change a menu item in response to a different command.
    Originally Posted by MCroft View Post
    Listener?
    Well, thank you.
    Originally Posted by Veracity View Post

  3. #13
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default


    I'm working my way around Listener. It definitely seems like the right approach. I've registered and fired a listener, but it's not actually calling my update(). Still more looking around to do. I don't think I've successfully registered it, if what I see in the debugger is correct.

    What I've got so far:
    1. Global Menu: new helper menu item that adds a note to the debug log. If Logging is Off, sets debug logging state on, updates with note, then sets logging state off.
    2. gCLI additions to existing debug command
      1. debug note <User Note> If <User Note> is not empty, follow on/off logic for global menu item for adding note.
      2. debug ? Responds with "Debugging is ON" if isDebugging() is true, else "Debugging is OFF"
      3. debug trace ? Responds with "Tracing is ON" if isTracing() is true, else "Tracing is OFF"
    3. ash command debugprint(String log), parallel to logprint and traceprint. Returns silently if debug log is off.


    So I've accomplished 3 of my 4 tasks, and am just working on changing the menu when the log starts for a reason other than the menu item was touched.

    My eventual thoughts on the ash command was "do it like the others". Since there's an ash command, there's also a debug print in the gCLI that works like the ash command. We may not need "note", although I like the stronger "do what you were told" logic that I implemented.

    In debugging the menu item, I found that GlobalMenuBar is created 10 times which isn't a problem unless you're registering a Listener in a menu item and maybe not then if you've done it right. It seems like if it is a global menu bar, maybe a singleton would make more sense? It's only called (AFAICT) from GenericFrame.java and CreateFrameRunnable.java

  4. #14
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    solved my listener problem.

    patch and zip of src/net/sourceforge/kolmafia/swingui/menu/DebugLogNoteMenuItem.java are attached.
    DebugMenuItem.patch and DebugLogNoteMenuItem.java.zip

    embarrassingly, I can't figure out how to add a new file to a diff if I can't add the file to SVN, so it's separate.

    I add a new listener to the NamedRegistryListener "(debug)". Debug is fired by RequestLogger and kicks off update() in the DebugMenuItem class. It fires when the debug log is stopped or started, and it reads RequestLogger.isDebugging() and sets the menu item accordingly. It doesn't matter how we get to RequestLogger, the menu item reflects the current debugging state at the last change.

    There's some copied code and some places might be verbose, but it seems like it's working and resilient. Let me know if you have any changes you want me to make.


    Code:
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                  KoLmafia v20.7, Mac OS X, Java 13.0.2
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Please note: do not post this log in the KoLmafia thread of KoL's
     Gameplay-Discussion forum. If you would like the KoLmafia dev team
     to look at it, please write a bug report at kolmafia.us. Include
     specific information about what you were doing when you made this
     and include this log as an attachment.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Timestamp: Tue Oct 06 21:58:58 CDT 2020
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     User: Darwinlet
     Current run: 537
     MRU Script: Unknown
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    
    -----User Note: Tue Oct 06 21:58:58 CDT 2020-----
    I am a note from the menu.
    -----
    
    
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                  KoLmafia v20.7, Mac OS X, Java 13.0.2
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Please note: do not post this log in the KoLmafia thread of KoL's
     Gameplay-Discussion forum. If you would like the KoLmafia dev team
     to look at it, please write a bug report at kolmafia.us. Include
     specific information about what you were doing when you made this
     and include this log as an attachment.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Timestamp: Tue Oct 06 21:59:24 CDT 2020
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     User: Darwinlet
     Current run: 537
     MRU Script: Unknown
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    
    -----User Note: Tue Oct 06 21:59:24 CDT 2020-----
    I am a note from the gCLI...
    -----
    
    
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                  KoLmafia v20.7, Mac OS X, Java 13.0.2
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Please note: do not post this log in the KoLmafia thread of KoL's
     Gameplay-Discussion forum. If you would like the KoLmafia dev team
     to look at it, please write a bug report at kolmafia.us. Include
     specific information about what you were doing when you made this
     and include this log as an attachment.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Timestamp: Tue Oct 06 21:59:38 CDT 2020
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     User: Darwinlet
     Current run: 537
     MRU Script: Unknown
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    
    > debug note I am a note after debug has been turned on...
    
    -----User Note: Tue Oct 06 21:59:53 CDT 2020-----
    I am a note after debug has been turned on...
    -----
    > ash debugprint("and I am a note from ash...");
    
    -----User Note: Tue Oct 06 22:00:14 CDT 2020-----
    and I am a note from ash...
    -----
    Returned: void
    
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                  KoLmafia v20.7, Mac OS X, Java 13.0.2
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Please note: do not post this log in the KoLmafia thread of KoL's
     Gameplay-Discussion forum. If you would like the KoLmafia dev team
     to look at it, please write a bug report at kolmafia.us. Include
     specific information about what you were doing when you made this
     and include this log as an attachment.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     Timestamp: Tue Oct 06 22:18:45 CDT 2020
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     User: Darwinlet
     Current run: 537
     MRU Script: Unknown
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    
    > help debug
    
    debug [on] | off | ? | note | trace [ [on] | off | ? ] | ash [ [on] | off ] | listener [ [on] | off ] - start or stop logging of debugging data.
    [...]
    > debug off

  5. #15
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default Please review patch

    this patch is complete if anyone is available to review it.

    In addition to the feature I wanted, it also makes the debug menu item sync with the debug on/off state when you start it from the gCLI, so some improvements and some newness.

  6. #16
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    this patch is complete if anyone is available to review it.

    In addition to the feature I wanted, it also makes the debug menu item sync with the debug on/off state when you start it from the gCLI, so some improvements and some newness.
    Originally Posted by MCroft View Post
    Downloaded it. No promises. To maintain plausible deniability, you have tested this within an inch (no metric for me) of its life, right? So I can focus on code and style and minimal functionality?

    I use TortoiseSVN. There is a command to add a new file. You use it when you want to include a previously non-existent file in the next commit. My recollection is that files so added are included when building a patch. Not sure what you are using but there has to be an equivalent command.
    Well, thank you.
    Originally Posted by Veracity View Post

  7. #17
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    Patch doesn't apply and is taking more time than I want to give to force it.

    Would you consider adding the new file and then recreating the patch. The root of my Kolmafia source tree is D:\kolmafia and people have had the best results with my patches if that is the directory I start from when I make the patch.

  8. #18
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    sure, I'll work on a better patch. I definitely don't want to make this hard, since you're doing me a favor by reviewing this.

    I was thinking I can't add files because I don't have commit rights, but I may be overthinking things.

  9. #19
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,671

    Default

    The "commit rights" only matter when you try to commit. Setting up a commit by editing files - and adding new ones - should be possible regardless.

  10. #20
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    and of course, now that I second-guess myself, it's obvious. You add file and it stages it locally and it appears in patches.
    My test of the (new) patch: DebugNotes.patch
    1: get a clean instance of KoLmafia ("instance3", in my case) & update it.
    2: put the patch in the top level KoLmafia directory (next to src and build.xml).
    3: patch -p0 <DebugNotes.patch
    4: ant daily
    5: java -jar dist/KoL*.jar

    Then I could check out the ask, gCLI, and menu items.

    Code:
    Michaels-MBP:projects mcroft$ cd instance3
    Michaels-MBP:instance3 mcroft$ ls
    bin                build.xml          default.properties kolmafia.iml       src                util
    build.properties   data               devdoc             lib                test
    Michaels-MBP:instance3 mcroft$ ant update
    Buildfile: /Users/mcroft/projects/instance3/build.xml
    
    update:
         [exec] Updating '.':
    [...]
         [exec] Updated to revision 20471.
    
    BUILD SUCCESSFUL
    Total time: 1 second
    Michaels-MBP:instance3 mcroft$ svn diff
    
    Michaels-MBP:instance3 mcroft$ cp ../kolmafia/DebugNotes.patch DebugNotes.patch
    
    Michaels-MBP:instance3 mcroft$ patch -p0 <DebugNotes.patch 
    patching file src/net/sourceforge/kolmafia/swingui/menu/DebugLogMenuItem.java
    patching file src/net/sourceforge/kolmafia/swingui/menu/DebugLogNoteMenuItem.java
    patching file src/net/sourceforge/kolmafia/swingui/menu/GlobalMenuBar.java
    patching file src/net/sourceforge/kolmafia/textui/command/DebugRequestCommand.java
    patching file src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java
    patching file src/net/sourceforge/kolmafia/RequestLogger.java
    Michaels-MBP:instance3 mcroft$ ant daily
    Buildfile: /Users/mcroft/projects/instance3/build.xml
    
    [...]
    
    BUILD SUCCESSFUL
    Total time: 24 seconds
    
    Michaels-MBP:instance3 mcroft$ java -jar dist/KoLmafia-20471M.jar
    
    KoLmafia v20.7 r20471
    Released on July 30, 2020
    
    Currently Running on Mac OS X
    Local Directory is /Users/mcroft/Library/Application Support/KoLmafia
    Using Java 13.0.2
    
    Michaels-MBP:instance3 mcroft$

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •