diff --git a/src/conf.c b/src/conf.c index b84f592..cf19436 100644 --- a/src/conf.c +++ b/src/conf.c @@ -51,6 +51,7 @@ static void print_help() "\t-h, --help Print this help and exit\n" "\t-v, --verbose Print verbose messages\n" "\t --debug Enable debug mode\n" + "\t --silent Suppress notices and warnings\n" "\t-s, --switchvt Automatically switch to VT\n", "kmscon"); } @@ -63,6 +64,7 @@ int conf_parse_argv(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "verbose", no_argument, NULL, 'v' }, { "debug", no_argument, &conf_global.debug, 1 }, + { "silent", no_argument, &conf_global.silent, 1 }, { "switchvt", no_argument, NULL, 's' }, { NULL, 0, NULL, 0 }, }; diff --git a/src/conf.h b/src/conf.h index 8d221b5..e92c329 100644 --- a/src/conf.h +++ b/src/conf.h @@ -49,6 +49,8 @@ struct conf_obj { int debug; /* enable verbose info messages */ int verbose; + /* disable notices and warnings */ + int silent; /* enter new VT directly */ int switchvt; }; diff --git a/src/log.h b/src/log.h index 688d20a..5f0c16a 100644 --- a/src/log.h +++ b/src/log.h @@ -133,6 +133,8 @@ struct log_config { LOG_CONFIG_ALL((debug), 2, 2, 2, 2, 2, 2) #define LOG_CONFIG_INFO(debug, info) \ LOG_CONFIG_ALL((debug), (info), 2, 2, 2, 2, 2) +#define LOG_CONFIG_WARNING(debug, info, notice, warning) \ + LOG_CONFIG_ALL((debug), (info), (notice), (warning), 2, 2, 2) void log_set_config(const struct log_config *config); int log_add_filter(const struct log_filter *filter, diff --git a/src/main.c b/src/main.c index b66b85c..ae08498 100644 --- a/src/main.c +++ b/src/main.c @@ -142,9 +142,13 @@ int main(int argc, char **argv) if (conf_global.exit) return EXIT_SUCCESS; + if (!conf_global.debug && !conf_global.verbose && conf_global.silent) + log_set_config(&LOG_CONFIG_WARNING(0, 0, 0, 0)); + else + log_set_config(&LOG_CONFIG_INFO(conf_global.debug, + conf_global.verbose)); + log_print_init("kmscon"); - log_set_config(&LOG_CONFIG_INFO(conf_global.debug, - conf_global.verbose)); memset(&app, 0, sizeof(app)); ret = setup_app(&app);