osmo-trx: Re-introduce -l cmd line parameter

Parameter -l to set the terminal logging levle was removed in
3da1f8352e, 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
This commit is contained in:
Pau Espin 2018-03-06 18:38:22 +01:00
parent 408f25081e
commit 8dffadb8da
1 changed files with 6 additions and 1 deletions

View File

@ -211,7 +211,7 @@ static void handle_options(int argc, char **argv, struct trx_ctx* trx)
std::vector<std::string> 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;