log.c: New log_init() function, called at initial bootstrap

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-07-02 12:34:12 +02:00
parent 1036c365b8
commit bd54cf6dee
3 changed files with 17 additions and 4 deletions
+8 -4
View File
@@ -43,23 +43,27 @@ static int parse_conf(char *file);
void conf_parse_cmdline(void)
{
int dbg = 0, qit = 0;
FILE *fp;
char line[LINE_SIZE];
fp = fopen("/proc/cmdline", "r");
if (fp) {
char line[LINE_SIZE];
fgets(line, sizeof(line), fp);
chomp(line);
_d("%s", line);
if (strstr(line, "finit_debug") || strstr(line, "--debug"))
debug = 1;
dbg = 1;
if (!debug && strstr(line, "quiet"))
quiet = 1;
if (strstr(line, "quiet"))
qit = 1;
fclose(fp);
}
log_init(qit, dbg);
}
/* Convert optional "[!123456789S]" string into a bitmask */
+8
View File
@@ -32,6 +32,14 @@
static int loglevel = LOG_NOTICE;
void log_init(int qit, int dbg)
{
if (dbg)
debug = 1;
if (!dbg && qit)
quiet = 1;
}
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
void log_exit(void)
{
+1
View File
@@ -40,6 +40,7 @@
#define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt "\n", __func__, ##args)
#define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %m\n", __func__, ##args)
void log_init (int qit, int dbg);
void log_exit (void);
void log_debug (void);