pybatmesh/naxalnet/log.py
Pranav Jerry ca1e721c9e
fixed logging issue and another bug
There was a problem with indentation which made the line starting adhoc
not being run at all.
Updated CHANGELOG
Moved some things to other places
log.py is back! It isn't needed, but it doesn't do any harm anyway.
2021-09-07 18:45:11 +05:30

39 lines
923 B
Python

"""
log.py
------
Initialise the logger for other submodules to import. Do not
import any submodules here except for naxallnet.config
"""
import logging
from systemd.journal import JournalHandler
from naxalnet.config import args
def get_logger():
"""
Initialise the logger and return it.
This function is meant to be used only by naxalnet.log.
If you want to import the logger, use:
from naxalnet.log import logger
"""
log = logging.getLogger("naxalnet")
# --verbose
if args.verbose >= 2:
loglevel = logging.DEBUG
elif args.verbose == 1:
loglevel = logging.INFO
else:
loglevel = logging.WARNING
# if --systemd is given, log to systemd journal
if args.systemd:
logging.basicConfig(level=logging.DEBUG)
log.addHandler(JournalHandler())
else:
logging.basicConfig(level=loglevel)
return log
logger = get_logger()