From 8dffadb8da92e7b0af97362936a117ebfbd9323d Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 6 Mar 2018 18:38:22 +0100 Subject: [PATCH] osmo-trx: Re-introduce -l cmd line parameter Parameter -l to set the terminal logging levle was removed in 3da1f8352e337fb032bf7a58c2909d3ba918e237, but afterwards it was decided to keep the cmd line options for a bit more to easy migration to VTY cfg. The command line no longer accepts keywords ("DEBUG", "INFO", etc.) but log level numbers, due to libosmocore APIs log_parse_level and log_level_str being marked as deprecated and for internal use only. Keep in mind the log level is overridden by VTY cfg if any line sets log levels for log stderr in there. Explicit cast to unsigned int for loglvel is issued to avoid iostream printing it as a char. Change-Id: I91c35ecded177b7976045d9b693855adb9e18f8a --- Transceiver52M/osmo-trx.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index f9755006..2eb8309d 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -211,7 +211,7 @@ static void handle_options(int argc, char **argv, struct trx_ctx* trx) std::vector rx_paths, tx_paths; bool rx_paths_set = false, tx_paths_set = false; - while ((option = getopt(argc, argv, "ha:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:C:")) != -1) { + while ((option = getopt(argc, argv, "ha:l:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:C:")) != -1) { switch (option) { case 'h': print_help(); @@ -221,6 +221,10 @@ static void handle_options(int argc, char **argv, struct trx_ctx* trx) print_deprecated(option); osmo_talloc_replace_string(trx, &trx->cfg.dev_args, optarg); break; + case 'l': + print_deprecated(option); + log_set_log_level(osmo_stderr_target, atoi(optarg)); + break; case 'i': print_deprecated(option); osmo_talloc_replace_string(trx, &trx->cfg.remote_addr, optarg); @@ -377,6 +381,7 @@ static void print_config(struct trx_ctx *trx) std::ostringstream ost(""); ost << "Config Settings" << std::endl; + ost << " Log Level............... " << (unsigned int) osmo_stderr_target->loglevel << std::endl; ost << " Device args............. " << charp2str(trx->cfg.dev_args) << std::endl; ost << " TRX Base Port........... " << trx->cfg.base_port << std::endl; ost << " TRX Address............. " << charp2str(trx->cfg.bind_addr) << std::endl;