From 253353daf565e55a91219b0f54d819a7e8552556 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Mar 2019 17:08:31 +0100 Subject: [PATCH] Introduce more logging levels --- p4app/controller.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/p4app/controller.py b/p4app/controller.py index 3602960..c4f209e 100644 --- a/p4app/controller.py +++ b/p4app/controller.py @@ -241,7 +241,6 @@ class L2Controller(object): dst_addr = pkg[IPv6].src src_addr = pkg[ICMPv6ND_NS].tgt - e = Ether(src=src_mac, dst=dst_mac) i = IPv6(src=src_addr, dst=dst_addr) @@ -249,12 +248,13 @@ class L2Controller(object): i2 = ICMPv6ND_NA(S=1, tgt=src_addr) i3 = ICMPv6NDOptSrcLLAddr(lladdr=src_mac) - self.debug_print_pkg(answer, "OUTGOING") answer = e / i / i2 / i3 + self.send_pkg(answer) + def send_pkg(self, pkg): + self.debug_print_pkg(pkg, "OUTGOING") sendp(answer, iface=self.intf, verbose=False) - def recv_msg_cpu(self, pkg): packet = Ether(str(pkg)) @@ -275,10 +275,10 @@ class L2Controller(object): if cpu_header.task == self.task['DEBUG']: log.debug("Debug purpose only") elif cpu_header.task == self.task['ICMP6_NS']: - log.debug("Doing neighbor solicitation") + log.info("Doing neighbor solicitation") self.handle_icmp6_ns(orig_packet) elif cpu_header.task == self.task['ICMP6_GENERAL']: - log.debug("Replying to ICMP packet") + log.info("Replying to ICMP packet") else: @@ -292,6 +292,7 @@ class L2Controller(object): parser = argparse.ArgumentParser(description='controller++') parser.add_argument('--mode', help='Select mode / settings to use', choices=self.modes) parser.add_argument('--debug', help='Enable debug logging', action='store_true') + parser.add_argument('--verbose', help='Enable verbose logging', action='store_true') parser.add_argument('--multicast-to-controller', help='Send debug multicast to controller', action='store_true') self.args = parser.parse_args() @@ -316,5 +317,10 @@ if __name__ == "__main__": controller.commandline() if controller.args.debug: log.setLevel(logging.DEBUG) + elif controller.args.verbose: + log.setLevel(logging.INFO) + else: + log.setLevel(logging.WARNING) + controller.config() controller.run_cpu_port_loop()