-
Notifications
You must be signed in to change notification settings - Fork 33
OllamaDebug: Command to show the debug log in a buffer #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Convenient while debugging the plugin.
7807d02 to
bd23f46
Compare
|
By the way, in which case log messages could be functions: call map(a:lines, { k, L -> type(L) == v:t_func ? call(L, []) : L })? Existing version will only evaluate functions after the on-disk log file update. elseif type(l:message) == v:t_func
" Evaluate deferred log lines.
" TODO When does this happen?
call add(l:lines, call(l:message, []))But it would be nice to add a note explaining when is it useful, if it really happens. |
Yes, after your last PR I started to clean up some things.
I did not write this part, but my explanation is the following. Often when logging data, you need to prepare some strings, which sometime is an expensive task (CPU and/or memory wise). If then the logger discards it due to a too low logging level you are wasting these resources. By using a function reference you can do these toString() conversion only when needed (lazy evaluation). |
|
Actually, the logging to buffer is only a fallback if logging to file didn't work. |
My version removes it, and the same functionality is implemented using Vim script.
The problem is, as written, this processing only happens when lines are stored in the in-memory log. I do not think that it saves anything, as all the logging in synchronous. There would have been a difference, should one of the execution paths would not evaluate the closure. But again, this does not work with a file log. So, it seems to me that this functionality is actually broken.
Yes, the in-memory log is currently only populated when the log file is not writable. Which, again, looks broken to me. I figured that as the in-memory log has an upper bound on the number of lines it may contain, it probably is not a problem from the memory standpoint. Note that the log will only ever contain this much data if debug logging level is set. By default, the in memory log will contain just a few messages. I was hoping that it could all work with a single command. Footnotes
|
Convenient while debugging the plugin.
Seems like we both worked on the same functionality in parallel.
You cleaned up the logging buffer here: 9f6a696
But I also had this change for a few days now.
There are a number of minor details that I was trying to polish here:
My change is based on the version before your last update.
But, I believe, my version contains all the functionality from your update, except that the command has a different name and is always created.
I think it is better to always create the command.
Otherwise, it could be confusing to the user.
Let me know if you want me to create a merge that would use more of your last update code.