jtavares has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/30154 )


Change subject: bankd, client, server: add -L option to disable log coloring
......................................................................

bankd, client, server: add -L option to disable log coloring

When the stderr of these services is sent to syslog, for example by
using systemd's StandardError=syslog, syslog's escaping of ANSI color
ESC sequences in log messages really clutter the log files. This
option allows log coloring to be disabled on the command line.

Change-Id: I6955b0af1ceb11a4029383e32bb298ee8da7503f
---
M src/bankd/bankd_main.c
M src/client/remsim_client_main.c
M src/server/remsim_server.c
3 files changed, 22 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/54/30154/1

diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index 3fd4d6b..063013e 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -301,6 +301,7 @@
 "  -s --permit-shared-pcsc      Permit SHARED access to PC/SC readers 
(default: exclusive)\n"
 "  -g --gsmtap-ip A.B.C.D       Enable GSMTAP and send APDU traces to given 
IP\n"
 "  -G --gsmtap-slot <0-1023>    Limit tracing to given bank slot, only 
(default: all slots)\n"
+"  -L --log-color-disable       Output log messages without color\n"
              );
 }

@@ -325,10 +326,11 @@
                        { "permit-shared-pcsc", 0, 0, 's' },
                        { "gsmtap-ip", 1, 0, 'g' },
                        { "gsmtap-slot", 1, 0, 'G' },
+                       { "log-color-disable", 0, 0, 'L' },
                        { 0, 0, 0, 0 }
                };

-               c = getopt_long(argc, argv, "hVd:i:p:b:n:N:I:P:sg:G:", 
long_options, &option_index);
+               c = getopt_long(argc, argv, "hVd:i:p:b:n:N:I:P:sg:G:L", 
long_options, &option_index);
                if (c == -1)
                        break;

@@ -374,6 +376,9 @@
                case 'G':
                        g_bankd->cfg.gsmtap_slot = atoi(optarg);
                        break;
+               case 'L':
+                       log_set_use_color(osmo_stderr_target, 0);
+                       break;
                }
        }
 }
diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
index 5a23d82..eb54310 100644
--- a/src/client/remsim_client_main.c
+++ b/src/client/remsim_client_main.c
@@ -35,6 +35,7 @@
                "  -a --atr HEXSTRING         default ATR to simulate (until 
bankd overrides it)\n"
                "  -r --atr-ignore-rspro      Ignore any ATR from bankd; use 
only ATR given by -a)\n"
                "  -e --event-script <path>   event script to be called by 
client\n"
+               "  -L --log-color-disable     Output log messages without 
color\n"
 #ifdef USB_SUPPORT
                "  -V --usb-vendor VENDOR_ID\n"
                "  -P --usb-product PRODUCT_ID\n"
@@ -64,6 +65,7 @@
                        { "atr", 1, 0, 'a' },
                        { "atr-ignore-rspro", 0, 0, 'r' },
                        { "event-script", 1, 0, 'e' },
+                       {" log-color-disable", 0, 0, 'L' },
 #ifdef USB_SUPPORT
                        { "usb-vendor", 1, 0, 'V' },
                        { "usb-product", 1, 0, 'P' },
@@ -76,7 +78,7 @@
                        { 0, 0, 0, 0 }
                };

-               c = getopt_long(argc, argv, "hvd:i:p:c:n:a:re:"
+               c = getopt_long(argc, argv, "hvd:i:p:c:n:a:re:L"
 #ifdef USB_SUPPORT
                                                "V:P:C:I:S:A:H:"
 #endif
@@ -122,6 +124,9 @@
                case 'e':
                        osmo_talloc_replace_string(cfg, &cfg->event_script, 
optarg);
                        break;
+               case 'L':
+                       log_set_use_color(osmo_stderr_target, 0);
+                       break;
 #ifdef USB_SUPPORT
                case 'V':
                        cfg->usb.vendor_id = strtol(optarg, NULL, 16);
diff --git a/src/server/remsim_server.c b/src/server/remsim_server.c
index 419dcad..7f5267c 100644
--- a/src/server/remsim_server.c
+++ b/src/server/remsim_server.c
@@ -33,9 +33,10 @@
 static void print_help()
 {
        printf( "  Some useful help...\n"
-               "  -h --help                    This text\n"
-               "  -V --version                 Print version of the program\n"
-               "  -d --debug option            Enable debug logging (e.g. 
DMAIN:DST2)\n"
+               "  -h --help                This text\n"
+               "  -V --version             Print version of the program\n"
+               "  -d --debug option        Enable debug logging (e.g. 
DMAIN:DST2)\n"
+               "  -L --log-color-disable   Output log messages without color\n"
                );
 }

@@ -47,10 +48,11 @@
                        { "help", 0, 0, 'h' },
                        { "version", 0, 0, 'V' },
                        { "debug", 1, 0, 'd' },
-                       {0, 0, 0, 0}
+                       { "log-color-disable", 0, 0, 'L' },
+                       { 0, 0, 0, 0 }
                };

-               c = getopt_long(argc, argv, "hVd:", long_options, 
&option_index);
+               c = getopt_long(argc, argv, "hVd:L", long_options, 
&option_index);
                if (c == -1)
                        break;

@@ -66,6 +68,9 @@
                        printf("osmo-resmim-server version %s\n", VERSION);
                        exit(0);
                        break;
+               case 'L':
+                       log_set_use_color(osmo_stderr_target, 0);
+                       break;
                default:
                        /* ignore */
                        break;

--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30154
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I6955b0af1ceb11a4029383e32bb298ee8da7503f
Gerrit-Change-Number: 30154
Gerrit-PatchSet: 1
Gerrit-Owner: jtavares <[email protected]>
Gerrit-MessageType: newchange

Reply via email to