mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
Fix initctl debug toggle regression introduced in ae09272b
Calling `initctl debug` is supposed to toggle Finit debug messages on
the boot console. This broke in ae09272b when improving support for
running Finit in containers.
Part of this change is a slight refactor of who calles log_init() when
starting up, and when to call ttinit(). We now call ttinit() every time
we toggle debug.
Also, toggling back to normal logging had a bug. The new default log
level for Finit is LOG_INFO, but toggling back set it to LOG_NOTICE.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -205,8 +205,6 @@ void conf_parse_cmdline(int argc, char *argv[])
|
||||
|
||||
parse_kernel_cmdline();
|
||||
parse_kernel_loglevel();
|
||||
|
||||
log_init();
|
||||
}
|
||||
|
||||
static int kmod_exists(char *mod)
|
||||
|
||||
+3
-3
@@ -570,7 +570,7 @@ int main(int argc, char *argv[])
|
||||
};
|
||||
uev_ctx_t loop;
|
||||
|
||||
/* telinit or stand-alone process monitor */
|
||||
/* user calling telinit or init */
|
||||
if (getpid() != 1)
|
||||
return telinit(argc, argv);
|
||||
|
||||
@@ -581,12 +581,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
/*
|
||||
* Parse /proc/cmdline (debug, rescue, console=, etc.)
|
||||
* Also calls log_init() to set correct log level
|
||||
*/
|
||||
conf_parse_cmdline(argc, argv);
|
||||
|
||||
/*
|
||||
* Figure out system console(s)
|
||||
* Figure out system console(s) and call log_init() to set
|
||||
* correct log level, possibly finit.debug enabled.
|
||||
*/
|
||||
console_init();
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ char *console(void)
|
||||
|
||||
void console_init(void)
|
||||
{
|
||||
ttinit();
|
||||
log_init();
|
||||
}
|
||||
|
||||
ssize_t cprintf(const char *fmt, ...)
|
||||
|
||||
@@ -40,6 +40,8 @@ static int loglevel = LOG_INFO;
|
||||
|
||||
void log_init(void)
|
||||
{
|
||||
ttinit();
|
||||
|
||||
if (debug)
|
||||
loglevel = LOG_DEBUG;
|
||||
else
|
||||
@@ -72,24 +74,25 @@ static int log_open(void)
|
||||
if (debug)
|
||||
opts |= LOG_PERROR;
|
||||
|
||||
closelog();
|
||||
openlog("finit", opts, LOG_DAEMON);
|
||||
setlogmask(LOG_UPTO(loglevel));
|
||||
|
||||
return up = 1;
|
||||
}
|
||||
|
||||
static void log_close(void)
|
||||
{
|
||||
closelog();
|
||||
up = 0;
|
||||
}
|
||||
|
||||
/* Toggle debug mode */
|
||||
void log_debug(void)
|
||||
{
|
||||
debug = !debug;
|
||||
|
||||
if (debug) {
|
||||
loglevel = LOG_DEBUG;
|
||||
} else {
|
||||
loglevel = LOG_NOTICE;
|
||||
ttinit();
|
||||
}
|
||||
log_close();
|
||||
log_init();
|
||||
log_open();
|
||||
|
||||
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
|
||||
|
||||
Reference in New Issue
Block a user