Försöker att förbättra loggningen
This commit is contained in:
@@ -17,9 +17,9 @@ def configure():
|
||||
Reads YAML configruation file into dictionary, parse it and fill all referenceed
|
||||
environment variables with their values.
|
||||
"""
|
||||
##################
|
||||
####################################
|
||||
# Read YAML config
|
||||
##################
|
||||
####################################
|
||||
# Load configuration file that defines parameters for services
|
||||
with open('./smartassist/config/smartassist.yaml') as f:
|
||||
config = yaml.safe_load(f)
|
||||
@@ -41,19 +41,17 @@ def configure():
|
||||
# Update the config dictionary with resolved environment variables
|
||||
updated_config = update_dict_with_env_vars(config)
|
||||
|
||||
##################
|
||||
####################################
|
||||
# Extract global logging level
|
||||
##################
|
||||
# The log_level variable will be used by the logger module to set the log level
|
||||
# global log_level # Must be defined within function if referencing the global variable log_level defined outside this function
|
||||
####################################
|
||||
if isinstance(updated_config.get('logging'), dict): # Look for 'logging' key in config file
|
||||
logging_config = updated_config['logging']
|
||||
if isinstance(logging_config.get('level'), str): # Set to value of the yaml file if specified
|
||||
utils.log_level = logging_config['level']
|
||||
logger.info("Logging level set to: {}".format(utils.log_level))
|
||||
|
||||
|
||||
set_local_logger(logger) # Set log level for logger based on log_level
|
||||
|
||||
logger.debug("Logging level of startservices' logger has been configured")
|
||||
return updated_config
|
||||
|
||||
|
||||
@@ -67,12 +65,12 @@ def start_frontend(config):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.bind((hostname, port))
|
||||
logger.info("No server is running on %s -— starting one.", parsed_url.netloc)
|
||||
logger.debug("No server is running on %s -— starting one.", parsed_url.netloc)
|
||||
# Start frontend (web server) as a separate process
|
||||
subprocess.Popen(["python", "-m", "http.server", str(port)])
|
||||
except socket.error as e:
|
||||
if e.errno == 48:
|
||||
logger.error("A server is already running on %s -— will use this.", parsed_url.netloc)
|
||||
logger.debug("A server is already running on %s -— will use this.", parsed_url.netloc)
|
||||
else:
|
||||
raise # Unexpected error, re-raise it so we can see the traceback
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user