From cdf349bc645d36645dab13e3f975b4deafbee579 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 7 Dec 2018 09:34:00 +0700 Subject: trx_toolkit: introduce logging configuration arguments Before this change, it was impossible to configure logging parameters from command line, such as log level and format. This change introduces the following optional arguments: --log-level - logging level for stderr (by default, DEBUG); --log-format - logging message format for stderr; --log-file-name - enable logging to a given file; --log-file-level - logging level for file (by default, DEBUG); --log-file-format - logging message format for file; which are defined in a new class called ApplicationBase, so all existing applications should inherit them now. Change-Id: Ic3b0440cd73946ad444bd7e48feb7a92d45f6488 --- src/target/trx_toolkit/trx_sniff.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/target/trx_toolkit/trx_sniff.py') diff --git a/src/target/trx_toolkit/trx_sniff.py b/src/target/trx_toolkit/trx_sniff.py index 9fb567ed..7a873510 100755 --- a/src/target/trx_toolkit/trx_sniff.py +++ b/src/target/trx_toolkit/trx_sniff.py @@ -32,10 +32,11 @@ import sys import scapy.all +from app_common import ApplicationBase from data_dump import DATADumpFile from data_msg import * -class Application: +class Application(ApplicationBase): # Counters cnt_burst_dropped_num = 0 cnt_burst_num = 0 @@ -51,8 +52,7 @@ class Application: self.argv = self.parse_argv() # Configure logging - log.basicConfig(level = log.DEBUG, - format = "[%(levelname)s] %(filename)s:%(lineno)d %(message)s") + self.app_init_logging(self.argv) # Open requested capture file if self.argv.output_file is not None: @@ -195,6 +195,9 @@ class Application: dest = "verbose", action = "store_true", help = "Print burst bits to stdout") + # Register common logging options + self.app_reg_logging_options(parser) + trx_group = parser.add_argument_group("TRX interface") trx_group.add_argument("-i", "--sniff-interface", dest = "sniff_if", type = str, default = "lo", metavar = "IF", -- cgit v1.2.3