diff --git a/configure.ac b/configure.ac index a4734b9e..045425c8 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. # this defines the CORE version number, must be static for AC_INIT -AC_INIT(core, 5.5.0) +AC_INIT(core, 5.5.1) # autoconf and automake initialization AC_CONFIG_SRCDIR([netns/version.h.in]) diff --git a/daemon/core/utils.py b/daemon/core/utils.py index 425fc0ac..20d2384e 100644 --- a/daemon/core/utils.py +++ b/daemon/core/utils.py @@ -16,7 +16,6 @@ import sys from past.builtins import basestring -from core import constants from core.errors import CoreCommandError DEVNULL = open(os.devnull, "wb") @@ -451,16 +450,13 @@ def load_classes(path, clazz): return classes -def load_logging_config(config_path=None): +def load_logging_config(config_path): """ Load CORE logging configuration file. - :param str config_path: path to logging config file, - when None defaults to /etc/core/logging.conf + :param str config_path: path to logging config file :return: nothing """ - if not config_path: - config_path = os.path.join(constants.CORE_CONF_DIR, "logging.conf") with open(config_path, "r") as log_config_file: log_config = json.load(log_config_file) logging.config.dictConfig(log_config) diff --git a/daemon/examples/python/emane80211.py b/daemon/examples/python/emane80211.py index 7cbfd586..0e42be95 100644 --- a/daemon/examples/python/emane80211.py +++ b/daemon/examples/python/emane80211.py @@ -3,6 +3,7 @@ # Example CORE Python script that attaches N nodes to an EMANE 802.11abg network. import datetime +import logging import parser from builtins import range @@ -10,9 +11,6 @@ from core.emane.ieee80211abg import EmaneIeee80211abgModel from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes from core.emulator.enumerations import EventTypes -from core.utils import load_logging_config - -load_logging_config() def example(options): @@ -52,6 +50,7 @@ def example(options): def main(): + logging.basicConfig(level=logging.INFO) options = parser.parse_options("emane80211") start = datetime.datetime.now() print( diff --git a/daemon/examples/python/switch.py b/daemon/examples/python/switch.py index 5b086d6a..d669478d 100644 --- a/daemon/examples/python/switch.py +++ b/daemon/examples/python/switch.py @@ -6,15 +6,13 @@ # nodestep import datetime +import logging import parser from builtins import range from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes from core.emulator.enumerations import EventTypes, NodeTypes -from core.utils import load_logging_config - -load_logging_config() def example(options): @@ -56,8 +54,8 @@ def example(options): def main(): + logging.basicConfig(level=logging.INFO) options = parser.parse_options("switch") - start = datetime.datetime.now() print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time)) example(options) diff --git a/daemon/examples/python/switch_inject.py b/daemon/examples/python/switch_inject.py index b8587760..ff1ff84b 100644 --- a/daemon/examples/python/switch_inject.py +++ b/daemon/examples/python/switch_inject.py @@ -4,13 +4,11 @@ # n nodes are connected to a virtual wlan; run test for testsec # and repeat for minnodes <= n <= maxnodes with a step size of # nodestep +import logging from builtins import range from core.emulator.emudata import IpPrefixes from core.emulator.enumerations import EventTypes, NodeTypes -from core.utils import load_logging_config - -load_logging_config() def example(nodes): @@ -38,4 +36,5 @@ def example(nodes): if __name__ in {"__main__", "__builtin__"}: + logging.basicConfig(level=logging.INFO) example(2) diff --git a/daemon/examples/python/wlan.py b/daemon/examples/python/wlan.py index f94fd528..376f34d0 100644 --- a/daemon/examples/python/wlan.py +++ b/daemon/examples/python/wlan.py @@ -6,6 +6,7 @@ # nodestep import datetime +import logging import parser from builtins import range @@ -13,9 +14,6 @@ from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.enumerations import EventTypes, NodeTypes from core.location.mobility import BasicRangeModel -from core.utils import load_logging_config - -load_logging_config() def example(options): @@ -60,6 +58,7 @@ def example(options): def main(): + logging.basicConfig(level=logging.INFO) options = parser.parse_options("wlan") start = datetime.datetime.now() diff --git a/daemon/scripts/core-daemon b/daemon/scripts/core-daemon index 4becdaa1..07c6a9a7 100755 --- a/daemon/scripts/core-daemon +++ b/daemon/scripts/core-daemon @@ -7,6 +7,7 @@ message handlers are defined and some support for sending messages. import argparse import logging +import os import sys import threading import time @@ -96,7 +97,7 @@ def get_merged_config(filename): "numthreads": "1", "grpcport": "50051", "grpcaddress": "localhost", - "logfile": "" + "logfile": os.path.join(constants.CORE_CONF_DIR, "logging.conf") } parser = argparse.ArgumentParser( @@ -125,9 +126,6 @@ def get_merged_config(filename): cfg = ConfigParser(defaults) cfg.read(filename) - # load logging configuration - load_logging_config(args.logfile) - section = "core-daemon" if not cfg.has_section(section): cfg.add_section(section) @@ -149,6 +147,10 @@ def main(): """ # get a configuration merged from config file and command-line arguments cfg = get_merged_config("%s/core.conf" % constants.CORE_CONF_DIR) + + # load logging configuration + load_logging_config(cfg["logfile"]) + banner() try: