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
Add debug_level/debug_file options #448
Conversation
Does the init.h options documentation are enough for this advanced stuff (they are appended at the end of manual), or should I create a new section in the manual ? |
I think we should be consistent with respect to log rotation. In your current approach:
Wouldn't it be acceptable to have a If we proceed like this, you could have |
I have hesitated to do append the '%d' too, so if other agree, I will do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, there's one error that breaks compilation with debug disabled, that shall be fixed ☺
Then I agree with @gahr, the log rotate logic should be applied no matter what, if only to make it less likely to overwrite an existing log file.
I believe an environment variable and/or CLI argument should be used in complement of the setting value for setting up target of startup logs.
A timestamp should be written at the start of any given log file (not directly related to the PR, but as you're at it 😉)
init.c
Outdated
@@ -2336,6 +2403,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) | |||
strfcpy (scratch, tmp->data, sizeof (scratch)); | |||
mutt_expand_path (scratch, sizeof (scratch)); | |||
*((char **) MuttVars[idx].data) = safe_strdup (scratch); | |||
if (mutt_strcmp (MuttVars[idx].option, "debug_file") == 0) | |||
restart_debug (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build is broken, certainly because when DEBUG
is not defined, this line cannot compile.
init.c
Outdated
{ | ||
if (*ptr < 0) | ||
*ptr = 0; | ||
restart_debug (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
timestamps are already added by mutt_debug() |
@guyzmo all your points have been fixed. |
init.c
Outdated
safe_fclose(&debugfile); | ||
} | ||
|
||
memcpy(&debuglevel, &DebugLevel, sizeof(int)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debuglevel = DebugLevel ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously. done.
I'm not sure it's wise to restart debug upon a change in debug_level. Why is that needed? |
@gahr I have added new logic to not restart debug when just debug_level is changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks nice, but a simple use case doesn't work: setting a different log file/level in muttrc.
set debug_file = "~/logs/muttdebug"
set debug_level = 3
Now run, mutt -d2
Mutt creates the file ~/.muttdebug0
containing a line: "... debugging at level 2"
Within mutt:
set ?debug_file
replies~/logs/muttdebug
set ?debug_level
replies3
@flatcap that was just a logging issue, when the level change nothing was printed, I fixed that. Also in current implementation, muttrc is loaded after the debug is started, so "set devel_level = 3" will override any mutt -d option. |
OK, that's better.
Hmm... Is that what we want? I'd expect the command line to have a higher priority than the config file. ATM, if I run |
Hmm... Is that what we want? I'd expect the command line to have a higher priority than the config file.
(I suppose ideally, we'd have a debugfile command line option too)
I would prefer to have command line that override muttrc, too.
ATM, if I run `mutt -d 2` then mutt creates `~/muttdebug0` before it reads the `set debug_file` line in my config. I can't prevent it creating that file.
I have kept that to allow to debug the init as earlier as possible,
especially to have the muttrc parsing. But adding a new command line
option to override debug_file on startup will solve that.
So to resume my next version:
* setting only debug* in muttrc, will start the debug when the line is read
from the config file.
* Setting debug* on command line will start the debug at init beginning.
* Setting both, command line always wins.
|
48f03ff
to
9d672bb
Compare
Ah, I see. <thinking aloud> Hmm... does the file parsing actually have any debugging?
Could we do something like the linux kernel at startup? It stores its messages in a ring buffer, that gets dumped as soon as there's a tty. </thinking>
Great! Thanks. |
6dd8276
to
a730c99
Compare
Merged in 40f81d1. Thanks. |
This change allows to change debug_level and debug_file on the fly.
We can't really debug the early startup of mutt with these new options.
To solve #445
Does this PR meet the acceptance criteria?
syntax
What are the relevant issue numbers?
Closes #445