From 3764561bd59cac22aa4c8f5ea811eebc140af51b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 15 Jul 2012 23:37:46 +0200 Subject: [PATCH] fade: Add --loglevel option. All the infrastructure is already in place, so this patch is quite simple. --- fade.c | 6 +++++- m4/gengetopt/fade.m4 | 1 + m4/gengetopt/makefile | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fade.c b/fade.c index cbfb6230..2954fa32 100644 --- a/fade.c +++ b/fade.c @@ -25,12 +25,15 @@ DECLARE_MIXER_INITS; static struct mixer supported_mixer[] = {MIXER_ARRAY}; #define FOR_EACH_MIXER(i) for ((i) = 0; (i) < NUM_SUPPORTED_MIXERS; (i)++) -__printf_2_3 void date_log(__a_unused int ll, const char *fmt, ...) +static int loglevel; +__printf_2_3 void date_log(int ll, const char *fmt, ...) { va_list argp; time_t t1; struct tm *tm; + if (ll < loglevel) + return; time(&t1); tm = localtime(&t1); printf("%d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -309,6 +312,7 @@ int main(int argc, char *argv[]) fade_cmdline_parser_config_file(conf.config_file_arg, &conf, ¶ms); } + loglevel = get_loglevel_by_name(conf.loglevel_arg); init_mixers(); m = get_mixer_or_die(); ret = m->open(conf.mixer_device_arg, &h); diff --git a/m4/gengetopt/fade.m4 b/m4/gengetopt/fade.m4 index 7aab0521..da7a27e2 100644 --- a/m4/gengetopt/fade.m4 +++ b/m4/gengetopt/fade.m4 @@ -9,6 +9,7 @@ section "General options" include(config_file.m4) +include(loglevel.m4) option "mode" o #~~~~~~~~~~~~~~ diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index c613816f..c81eda46 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -33,6 +33,7 @@ $(ggo_dir)/client.ggo: \ $(m4_ggo_dir)/config_file.m4 \ $(m4_ggo_dir)/history_file.m4 \ $(m4_ggo_dir)/complete.m4 +$(ggo_dir)/fade.ggo: $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/config_file.m4 $(ggo_dir)/%.ggo: $(m4_ggo_dir)/%.m4 $(m4_ggo_dir)/header.m4 | $(ggo_dir) @[ -z "$(Q)" ] || echo 'M4 $<' -- 2.39.5