mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00:00
log.c: New functions to hide access to quiet and silent flags
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
60df2f2ea9
commit
cd947a69a8
6 files changed
+24
-13
No files matched your search
+4
-9
@@ -47,8 +47,6 @@
|
|||||||
#include "utmp-api.h"
|
#include "utmp-api.h"
|
||||||
#include "watchdog.h"
|
#include "watchdog.h"
|
||||||
|
|
||||||
int quiet = QUIET_MODE; /* Delayed disable of silent mode. */
|
|
||||||
int silent = SILENT_MODE; /* Completely silent, including boot */
|
|
||||||
int wdogpid = 0; /* No watchdog by default */
|
int wdogpid = 0; /* No watchdog by default */
|
||||||
int runlevel = 0; /* Bootstrap 'S' */
|
int runlevel = 0; /* Bootstrap 'S' */
|
||||||
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
|
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
|
||||||
@@ -63,17 +61,15 @@ char *console = NULL;
|
|||||||
|
|
||||||
uev_ctx_t *ctx = NULL; /* Main loop context */
|
uev_ctx_t *ctx = NULL; /* Main loop context */
|
||||||
|
|
||||||
static int banner(void)
|
static void banner(void)
|
||||||
{
|
{
|
||||||
char buf[42] = INIT_HEADING;
|
char buf[42] = INIT_HEADING;
|
||||||
const char separator[] = "========================================================================";
|
const char separator[] = "========================================================================";
|
||||||
|
|
||||||
if (silent)
|
if (log_is_silent())
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
fprintf(stderr, "\e[2K\e[1m%s %.*s\e[0m\n", buf, 66 - (int)strlen(buf), separator);
|
fprintf(stderr, "\e[2K\e[1m%s %.*s\e[0m\n", buf, 66 - (int)strlen(buf), separator);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Requires /proc to be mounted */
|
/* Requires /proc to be mounted */
|
||||||
@@ -422,8 +418,7 @@ int main(int argc, char* argv[])
|
|||||||
tty_runlevel(runlevel);
|
tty_runlevel(runlevel);
|
||||||
|
|
||||||
/* Enable silent mode, if selected */
|
/* Enable silent mode, if selected */
|
||||||
if (quiet && !debug)
|
log_silent();
|
||||||
silent = 1;
|
|
||||||
|
|
||||||
/* Start new initctl API responder */
|
/* Start new initctl API responder */
|
||||||
api_init(&loop);
|
api_init(&loop);
|
||||||
|
|||||||
@@ -89,8 +89,6 @@ struct init_request {
|
|||||||
char data[368];
|
char data[368];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int quiet;
|
|
||||||
extern int silent;
|
|
||||||
extern int wdogpid;
|
extern int wdogpid;
|
||||||
extern int runlevel;
|
extern int runlevel;
|
||||||
extern int cfglevel;
|
extern int cfglevel;
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ static void stty(int fd, speed_t speed)
|
|||||||
tcsetattr(fd, TCSANOW, &term);
|
tcsetattr(fd, TCSANOW, &term);
|
||||||
|
|
||||||
/* Clear screen in silent mode */
|
/* Clear screen in silent mode */
|
||||||
if (silent)
|
if (log_is_silent())
|
||||||
print("\033[r\033[H\033[J");
|
print("\033[r\033[H\033[J");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ void print(int action, const char *fmt, ...)
|
|||||||
const char pending[] = " \e[1m[ \\/ ]\e[0m\n";
|
const char pending[] = " \e[1m[ \\/ ]\e[0m\n";
|
||||||
const char dots[] = " .....................................................................";
|
const char dots[] = " .....................................................................";
|
||||||
|
|
||||||
if (silent)
|
if (log_is_silent())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
|
static int quiet = QUIET_MODE; /* Delayed disable of silent mode. */
|
||||||
|
static int silent = SILENT_MODE; /* Completely silent, including boot */
|
||||||
static int loglevel = LOG_NOTICE;
|
static int loglevel = LOG_NOTICE;
|
||||||
|
|
||||||
void log_init(int qit, int dbg)
|
void log_init(int qit, int dbg)
|
||||||
@@ -53,6 +55,19 @@ void log_exit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log_silent(void)
|
||||||
|
{
|
||||||
|
if (quiet && !debug)
|
||||||
|
silent = 1;
|
||||||
|
else
|
||||||
|
silent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int log_is_silent(void)
|
||||||
|
{
|
||||||
|
return silent;
|
||||||
|
}
|
||||||
|
|
||||||
void log_debug(void)
|
void log_debug(void)
|
||||||
{
|
{
|
||||||
debug = !debug;
|
debug = !debug;
|
||||||
|
|||||||
Reference in new issue
Block a user