Fix logging
This commit is contained in:
parent
4afa78713f
commit
7bad418850
10
pgmon.py
10
pgmon.py
@ -86,6 +86,7 @@ def init_logging(config):
|
||||
else:
|
||||
old_file_logger = None
|
||||
|
||||
if config.log_file is not None:
|
||||
# Create and add the handler if it doesn't exist
|
||||
if file_log_handler is None:
|
||||
file_log_handler = logging.FileHandler(config.log_file, encoding='utf-8')
|
||||
@ -104,7 +105,7 @@ def init_logging(config):
|
||||
logger.removeHandler(old_file_logger)
|
||||
|
||||
# Note where logs are being written
|
||||
print("Logging to {} ({})".format(config.log_file, config.file_log_level))
|
||||
#print("Logging to {} ({})".format(config.log_file, config.file_log_level))
|
||||
else:
|
||||
if file_log_handler is not None:
|
||||
logger.removeHandler(file_log_handler)
|
||||
@ -214,7 +215,7 @@ class Config:
|
||||
|
||||
self.stderr_log_level = 'INFO' # Log level for stderr logging (or 'off')
|
||||
self.file_log_level = 'INFO' # Log level for file logging (od 'off')
|
||||
self.log_file = 'pgmon.log' # Log file
|
||||
self.log_file = None # Log file
|
||||
|
||||
self.metrics = {} # Metrics
|
||||
self.clusters = {} # Known clusters
|
||||
@ -1088,7 +1089,7 @@ class Server:
|
||||
try:
|
||||
self.reload_config()
|
||||
except Exception as e:
|
||||
logger.ERROR("Reload failed: {}".format(e))
|
||||
logger.error("Reload failed: {}".format(e))
|
||||
|
||||
# If we just timed out waiting for a request, go back to waiting
|
||||
if conn is None:
|
||||
@ -1249,9 +1250,10 @@ class Worker(threading.Thread):
|
||||
continue
|
||||
|
||||
# Set the result on the request
|
||||
if metric.type == 'value':
|
||||
if len(res) == 0:
|
||||
req.set_result("Empty result set")
|
||||
elif metric.type == 'value':
|
||||
else:
|
||||
req.set_result("{}".format(list(res[0].values())[0]))
|
||||
elif metric.type == 'row':
|
||||
req.set_result(json.dumps(res[0]))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user