mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-19 18:17:37 +03:00
Gateway: Support --loglevel <level>
CL arg
NB: This required changes to src/eddn/conf/Settings.py as well, which means other scripts, e.g. Monitor.py, will also need changing.
This commit is contained in:
parent
872c65c280
commit
fb3c0348ad
@ -4,6 +4,7 @@
|
||||
Contains the necessary ZeroMQ socket and a helper function to publish
|
||||
market data to the Announcer daemons.
|
||||
"""
|
||||
import argparse
|
||||
import gevent
|
||||
import hashlib
|
||||
import logging
|
||||
@ -51,6 +52,27 @@ statsCollector = StatsCollector()
|
||||
statsCollector.start()
|
||||
|
||||
|
||||
def parse_cl_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='Gateway',
|
||||
description='EDDN Gateway server',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--loglevel',
|
||||
help='Logging level to output at',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-c', '--config',
|
||||
metavar='config filename',
|
||||
nargs='?',
|
||||
default=None,
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def extract_message_details(parsed_message):
|
||||
uploader_id = '<<UNKNOWN>>'
|
||||
software_name = '<<UNKNOWN>>'
|
||||
@ -342,7 +364,12 @@ class EnableCors(object):
|
||||
|
||||
|
||||
def main():
|
||||
loadConfig()
|
||||
|
||||
cl_args = parse_cl_args()
|
||||
if cl_args.loglevel:
|
||||
logger.setLevel(cl_args.loglevel)
|
||||
|
||||
loadConfig(cl_args)
|
||||
configure()
|
||||
|
||||
app.install(EnableCors())
|
||||
|
@ -134,15 +134,14 @@ class _Settings(object):
|
||||
Settings = _Settings()
|
||||
|
||||
|
||||
def loadConfig():
|
||||
'''
|
||||
Loads in a settings file specified on the commandline if one has been specified.
|
||||
def loadConfig(cl_args):
|
||||
"""
|
||||
Load in a commandline-specified settings file, if applicable.
|
||||
|
||||
A convenience method if you don't need other things specified as commandline
|
||||
options. Otherwise, point the filename to Settings.loadFrom().
|
||||
'''
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-c", "--config", nargs="?", default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config:
|
||||
Settings.loadFrom(args.config)
|
||||
:param cl_args: An `argparse.parse_args()` return.
|
||||
"""
|
||||
if cl_args.config:
|
||||
Settings.loadFrom(cl_args.config)
|
||||
|
Loading…
x
Reference in New Issue
Block a user