Commit 5d0f82a9 authored by Vasilis Tsiligiannis's avatar Vasilis Tsiligiannis

Consolidate loggers (fixes #281)

* Introduce setting for controlling log level and format
* Create separate logger per module
* Extend basic logger configuration instead of creating from scratch
Signed-off-by: Vasilis Tsiligiannis's avatarVasilis Tsiligiannis <acinonyx@openwrt.gr>
parent 3f0ee9ef
Pipeline #83235859 passed with stages
in 10 minutes and 1 second
......@@ -13,7 +13,7 @@ from validators.url import url
import satnogsclient.config
from satnogsclient.locator import locator
from satnogsclient.scheduler.tasks import exec_rigctld, status_listener
from satnogsclient.settings import DEFAULT_LOGGING, GPSD_ENABLED, \
from satnogsclient.settings import GPSD_ENABLED, LOG_FORMAT, LOG_LEVEL, \
SATNOGS_API_TOKEN, SATNOGS_NETWORK_API_URL, SATNOGS_STATION_ELEV, \
SATNOGS_STATION_ID, SATNOGS_STATION_LAT, SATNOGS_STATION_LON
......@@ -21,7 +21,8 @@ __author__ = satnogsclient.config.AUTHOR
__email__ = satnogsclient.config.EMAIL
__version__ = satnogsclient.config.VERSION
LOGGER = logging.getLogger('satnogsclient')
logging.basicConfig(format=LOG_FORMAT, level=getattr(logging, LOG_LEVEL))
LOGGER = logging.getLogger(__name__)
def main():
......@@ -48,7 +49,6 @@ def main():
if not SATNOGS_API_TOKEN:
raise Exception('SATNOGS_API_TOKEN not configured')
logging.config.dictConfig(DEFAULT_LOGGING)
LOGGER.info('Starting status listener thread...')
gps_locator = locator.Locator(120)
gps_locator.update_location()
......
......@@ -6,7 +6,7 @@ import gps
from satnogsclient import settings
LOGGER = logging.getLogger('satnogsclient')
LOGGER = logging.getLogger(__name__)
class Locator(object):
......
......@@ -3,7 +3,7 @@ from __future__ import absolute_import, division, print_function
import logging
import socket
LOGGER = logging.getLogger('satnogsclient')
LOGGER = logging.getLogger(__name__)
class Commsocket(object):
......
......@@ -24,7 +24,7 @@ except ImportError:
plt.switch_backend('Agg')
LOGGER = logging.getLogger('default')
LOGGER = logging.getLogger(__name__)
class Observer(object):
......
......@@ -7,7 +7,7 @@ from datetime import datetime
import ephem
import pytz
LOGGER = logging.getLogger('default')
LOGGER = logging.getLogger(__name__)
def pinpoint(observer_dict, satellite_dict, timestamp=None):
......
......@@ -15,7 +15,7 @@ from satnogsclient import settings
from satnogsclient.observer.commsocket import Commsocket
from satnogsclient.observer.orbital import pinpoint
LOGGER = logging.getLogger('default')
LOGGER = logging.getLogger(__name__)
class Worker(object):
......
......@@ -19,7 +19,7 @@ try:
except ImportError:
from urlparse import urljoin
LOGGER = logging.getLogger('default')
LOGGER = logging.getLogger(__name__)
LOG_PATH = settings.SATNOGS_OUTPUT_PATH + "/files/"
......
......@@ -99,27 +99,5 @@ SATNOGS_WATERFALL_MIN_VALUE = environ.get('SATNOGS_WATERFALL_MIN_VALUE', -100)
SATNOGS_WATERFALL_MAX_VALUE = environ.get('SATNOGS_WATERFALL_MAX_VALUE', -50)
# Logging configuration
DEFAULT_LOGGING = {
'version': 1,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'clientFormatter'
}
},
'loggers': {
'satnogsclient': {
'handlers': ['console'],
'level': 'INFO',
},
'apscheduler.executors.default': {
'handlers': ['console'],
'level': 'INFO',
}
},
'formatters': {
'clientFormatter': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
}
}
}
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
LOG_LEVEL = environ.get('SATNOGS_LOG_LEVEL', 'WARNING')
......@@ -7,7 +7,7 @@ import subprocess
from satnogsclient import settings as client_settings
LOGGER = logging.getLogger('default')
LOGGER = logging.getLogger(__name__)
def get_gnuradio_info():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment