hazelgrove / tylr

a tiny tile-based editor
https://tylr.fun
MIT License
284 stars 2 forks source link

Logging #15

Closed disconcision closed 2 years ago

disconcision commented 2 years ago

A comprehensive logging system. Certain actions are omitted; this is customizable; see predicated Log.is_action_logged. Everything is timestamped.

Additionally, all keystrokes including held modifiers are separately logged, along with the list of actions which each keystroke dispatches. Currently nothing is omitted here, though there is a predicate available similar to the above.

At the top of Log.re are debug flags which can be set to print logged actions and/or keystrokes to the console on every action/keystroke.

Press F9 to dump the action log to the console. Press F10 to dump the keystroke log to the console. Press F4 to reset both logs.

Caveats:

Currently the logs are stored as a string which is appended to each time. I'm doing this functionally; not sure if that will be a performance issue. We could alternatively store a serialized form if we want it, though the generated string should be trivial to parse.

Both logs are persistent in localstore. There is currently no formal delineation between refresh sessions, but you can track this in the action log by looking for the LoadInit action which is run only on startup.

actions:

Screen Shot 2022-06-23 at 11 44 31 PM

keystokes:

Screen Shot 2022-06-23 at 11 45 26 PM
disconcision commented 2 years ago

idea for log export design:

click a button in the topbar to copy the following json payload to clipboard:

{
  "keylog": [
     {
       "timestamp": "134534543534
       "key":  "DOWN a + SHIFT + ALT",
     },
     ...
   ],
  "actionlog" :  [
     {
       "timestamp": "134534543534"
       "action":  "(INSERT a)",
       "result": "SUCCESS"
     },
     ...
   ],
  "zipperlog" : [
     {
        "timestamp" : "11112340002342",
        "code": "let x = 5|",
        "selection": "",
        "backpack: ["in"] 
     },
     ...
   ],
}
cyrus- commented 2 years ago

looks reasonable. just FYI @dedbox has been doing some extensive debug logging in his Hazel branch, maybe you two should talk about whether there are overlaps / what the right approach is long term

disconcision commented 2 years ago

just ftr here's how the logging looks at merge time

Screen Shot 2022-06-24 at 6 58 39 PM

: