diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-27 08:58:57 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-27 19:01:37 +0100 |
commit | 63c0e6d1996733d107434585fbef5e888b3075ed (patch) | |
tree | 37973849e32a30cdd224d1873944212408f3913d /src/host/layer23/src/misc/app_cell_log.c | |
parent | 738f9d892aa99639c9148643923505f748e72937 (diff) |
layer23: Make the logfile configurable with cell_log
Be able to add extra (short) options from the 'applet' to
the main application. Use this to print the help mentioning
app specific options, pass the getopt string and handle the
command line parsing for it.
Change cell_log to keep the logname in the app_cell_log.c
and then access it from the cell_log.c implementation.
Diffstat (limited to 'src/host/layer23/src/misc/app_cell_log.c')
-rw-r--r-- | src/host/layer23/src/misc/app_cell_log.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/host/layer23/src/misc/app_cell_log.c b/src/host/layer23/src/misc/app_cell_log.c index a72588f7..e80a7b25 100644 --- a/src/host/layer23/src/misc/app_cell_log.c +++ b/src/host/layer23/src/misc/app_cell_log.c @@ -30,7 +30,12 @@ #include <osmocom/bb/common/logging.h> #include <osmocom/bb/misc/cell_log.h> +#include <osmocore/talloc.h> + extern struct log_target *stderr_target; +extern void *l23_ctx; + +char *logname = "/var/log/osmocom.log"; int _scan_work(struct osmocom_ms *ms) { @@ -77,9 +82,30 @@ static int l23_cfg_supported() return L23_OPT_TAP | L23_OPT_DBG; } +static int l23_cfg_print_help() +{ + printf("\nApplication specific\n"); + printf(" -l --logfile LOGFILE Logfile for the cell log.\n"); + return 0; +} + +static int l23_cfg_handle(int c, const char *optarg) +{ + switch (c) { + case 'l': + logname = talloc_strdup(l23_ctx, optarg); + break; + } + + return 0; +} + static struct l23_app_info info = { .copyright = "Copyright (C) 2010 Andreas Eversberg\n", + .getopt_string = "l:", .cfg_supported = l23_cfg_supported, + .cfg_handle_opt = l23_cfg_handle, + .cfg_print_help = l23_cfg_print_help, }; struct l23_app_info *l23_app_info() |