mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-12-03 12:11:01 +05:30
Pranav Jerry
2d9aee4d3a
When run without --systemd, naxalnet will log to stderr. Otherwise, it will log to systemd journal. log.py is no longer needed.
32 lines
658 B
Python
32 lines
658 B
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
log.py
|
|
------
|
|
|
|
This file contains the logger object, which is required for logging
|
|
to the systemd journal
|
|
"""
|
|
|
|
import logging
|
|
from systemd import journal
|
|
from naxalnet.config import parse_args
|
|
|
|
|
|
def get_logger():
|
|
"""returns the logger object for logging"""
|
|
|
|
args = parse_args()
|
|
if args.systemd:
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.DEBUG)
|
|
logger.addHandler(journal.JournalHandler())
|
|
else:
|
|
# logging.basicConfig(level=logging.DEBUG)
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.DEBUG)
|
|
return logger
|
|
|
|
|
|
logger = get_logger()
|