Skip to content

How to adjust the logging level #564

@senderic

Description

@senderic

I am using CoreEmu as an API for python tests and I am noticing a lot logging, such as this:

INFO:root:emane is not installed
INFO:root:created session: 1
INFO:root:opening xml: 1_multiple_links.xml
INFO:root:changing session(1) to state CONFIGURATION_STATE
INFO:root:reading default services for nodes(mdr): ['zebra', 'OSPFv3MDR', 'IPForward']
INFO:root:reading default services for nodes(PC): ['DefaultRoute']
INFO:root:reading default services for nodes(prouter): []
INFO:root:reading default services for nodes(router): ['zebra', 'OSPFv2', 'OSPFv3', 'IPForward']
INFO:root:reading default services for nodes(host): ['DefaultRoute', 'SSH']
INFO:root:reading session metadata: {'canvas c1': '{name {Canvas1}}', 'global_options': 'interface_names=yes ip_addresses=yes ipv6_addresses=no node_labels=yes link_labels=yes show_api=no background_images=no annotations=yes grid=yes traffic_start=0'}
INFO:root:reading session options: {'controlnet': '', 'controlnet0': '', 'controlnet1': '', 'controlnet2': '', 'controlnet3': '', 'controlnet_updown_script': '', 'enablerj45': '1', 'ovs': 'True', 'preservedir': '0', 'enablesdt': '0', 'sdturl': 'tcp://127.0.0.1:50000/'}
INFO:root:reading session reference geo: 47.5791667, -122.132322, 2.0
INFO:root:reading session reference scale: 150.0
INFO:root:reading node id(2) model(PC) name(mh60-n2)
INFO:root:creating node(CoreNode) id(2) name(mh60-n2) start(True)
INFO:root:setting services for node(mh60-n2): ['DefaultRoute']
INFO:root:setting node config services: []
INFO:root:reading node id(3) model(PC) name(mh60-n3)
INFO:root:creating node(CoreNode) id(3) name(mh60-n3) start(True)
INFO:root:setting services for node(mh60-n3): ['DefaultRoute']
...

And on and on.

I am trying to set the logging level to warning only for core here:

import logging
from core.emulator.coreemu import CoreEmu

logging.getLogger('core').setLevel(logging.WARNING) #I also tried 'CoreEmu' and a few other combinations to no affect.
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
                    datefmt=TIME_FORMAT, level=logging.INFO)

But I am not seeing any affect. It seems almost that the core is logging straight to root?

I am wondering if there is a best way to ensure the log messages generated within the Core/CoreEmu libraries, I can set it to logging.WARNING.

We are using Core 6.3.0. I know it is multiple versions behind, we are planning to upgrade however until then, hopefully the mechanism for adjusting the logging level is the same regardless.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions