Agent: Format config log messages so they are readable

This commit is contained in:
Mike Salvatore 2021-06-30 08:07:11 -04:00
parent 3fb8c06102
commit f3e797694b
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import json import json
import logging import logging
import platform import platform
from pprint import pformat
from socket import gethostname from socket import gethostname
from urllib.parse import urljoin from urllib.parse import urljoin
@ -206,10 +207,10 @@ class ControlClient(object):
try: try:
unknown_variables = WormConfiguration.from_kv(reply.json().get("config")) unknown_variables = WormConfiguration.from_kv(reply.json().get("config"))
LOG.info( formatted_config = pformat(
"New configuration was loaded from server: %r" WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
% (WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict()),)
) )
LOG.info(f"New configuration was loaded from server:\n{formatted_config}")
except Exception as exc: except Exception as exc:
# we don't continue with default conf here because it might be dangerous # we don't continue with default conf here because it might be dangerous
LOG.error( LOG.error(

View File

@ -6,6 +6,7 @@ import os
import sys import sys
import traceback import traceback
from multiprocessing import freeze_support from multiprocessing import freeze_support
from pprint import pformat
# dummy import for pyinstaller # dummy import for pyinstaller
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
@ -76,10 +77,8 @@ def main():
"default" % (config_file,) "default" % (config_file,)
) )
print( formatted_config = pformat(WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict()))
"Loaded Configuration: %r" print(f"Loaded Configuration:\n{formatted_config}")
% WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
)
# Make sure we're not in a machine that has the kill file # Make sure we're not in a machine that has the kill file
kill_path = ( kill_path = (