mirror of
https://github.com/troglobit/finit.git
synced 2026-11-01 13:10:32 +00: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:
1 parent
3d91112e0d
commit
01cb088e51
4 files changed
+14
-13
No files matched your search
@@ -205,8 +205,6 @@ void conf_parse_cmdline(int argc, char *argv[])
|
|||||||
|
|
||||||
parse_kernel_cmdline();
|
parse_kernel_cmdline();
|
||||||
parse_kernel_loglevel();
|
parse_kernel_loglevel();
|
||||||
|
|
||||||
log_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kmod_exists(char *mod)
|
static int kmod_exists(char *mod)
|
||||||
|
|||||||
+3
-3
@@ -570,7 +570,7 @@ int main(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
uev_ctx_t loop;
|
uev_ctx_t loop;
|
||||||
|
|
||||||
/* telinit or stand-alone process monitor */
|
/* user calling telinit or init */
|
||||||
if (getpid() != 1)
|
if (getpid() != 1)
|
||||||
return telinit(argc, argv);
|
return telinit(argc, argv);
|
||||||
|
|
||||||
@@ -581,12 +581,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse /proc/cmdline (debug, rescue, console=, etc.)
|
* Parse /proc/cmdline (debug, rescue, console=, etc.)
|
||||||
* Also calls log_init() to set correct log level
|
|
||||||
*/
|
*/
|
||||||
conf_parse_cmdline(argc, argv);
|
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();
|
console_init();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ char *console(void)
|
|||||||
|
|
||||||
void console_init(void)
|
void console_init(void)
|
||||||
{
|
{
|
||||||
ttinit();
|
log_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t cprintf(const char *fmt, ...)
|
ssize_t cprintf(const char *fmt, ...)
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ static int loglevel = LOG_INFO;
|
|||||||
|
|
||||||
void log_init(void)
|
void log_init(void)
|
||||||
{
|
{
|
||||||
|
ttinit();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
loglevel = LOG_DEBUG;
|
loglevel = LOG_DEBUG;
|
||||||
else
|
else
|
||||||
@@ -72,24 +74,25 @@ static int log_open(void)
|
|||||||
if (debug)
|
if (debug)
|
||||||
opts |= LOG_PERROR;
|
opts |= LOG_PERROR;
|
||||||
|
|
||||||
closelog();
|
|
||||||
openlog("finit", opts, LOG_DAEMON);
|
openlog("finit", opts, LOG_DAEMON);
|
||||||
setlogmask(LOG_UPTO(loglevel));
|
setlogmask(LOG_UPTO(loglevel));
|
||||||
|
|
||||||
return up = 1;
|
return up = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void log_close(void)
|
||||||
|
{
|
||||||
|
closelog();
|
||||||
|
up = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Toggle debug mode */
|
/* Toggle debug mode */
|
||||||
void log_debug(void)
|
void log_debug(void)
|
||||||
{
|
{
|
||||||
debug = !debug;
|
debug = !debug;
|
||||||
|
|
||||||
if (debug) {
|
log_close();
|
||||||
loglevel = LOG_DEBUG;
|
log_init();
|
||||||
} else {
|
|
||||||
loglevel = LOG_NOTICE;
|
|
||||||
ttinit();
|
|
||||||
}
|
|
||||||
log_open();
|
log_open();
|
||||||
|
|
||||||
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
|
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
|
||||||
|
|||||||
Reference in new issue
Block a user