Commit 771bc9ca authored by Lu Xu's avatar Lu Xu 👀

wip

parent 0d38b560
...@@ -36,11 +36,11 @@ md5sum = b34fe47a73890097fbc6ea6374aeb38d ...@@ -36,11 +36,11 @@ md5sum = b34fe47a73890097fbc6ea6374aeb38d
[lopcomm-rrh-software.jinja2.py] [lopcomm-rrh-software.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-software.jinja2.py _update_hash_filename_ = lopcomm-rrh-software.jinja2.py
md5sum = 4eb02bab7ba6a7a482c2b9bad0a3c084 md5sum = 4d43bd9e7e4c8f07078e1e1b2b732dc2
[template-enb] [template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = ad247f0ef9bc1ffd28fe2abee1cf6ed8 md5sum = c45c582a72bf6a0666dc64e24c79774f
[template-gnb] [template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg _update_hash_filename_ = instance-gnb.jinja2.cfg
......
...@@ -276,13 +276,13 @@ output = ${directory:script}/lopcomm-rrh-config.py ...@@ -276,13 +276,13 @@ output = ${directory:script}/lopcomm-rrh-config.py
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-software.log log-output = ${directory:var}/log/lopcomm-rrh-software.log
software-json-log-output = ${directory:var}/log/lopcomm-rrh-software.json.log software-output-json-log-output = ${directory:var}/log/lopcomm-rrh-software-output.json.log
context = context =
section directory directory section directory directory
section slap_configuration slap-configuration section slap_configuration slap-configuration
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
key log_file :log-output key log_file :log-output
key software_json_log_file :software-json-log-output key software_output_json_log_file :software-output-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }} raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs raw python_path {{ buildout_directory}}/bin/pythonwitheggs
raw software_install_template {{ software_install_template }} raw software_install_template {{ software_install_template }}
......
...@@ -15,22 +15,22 @@ class LopcommNetconfClient: ...@@ -15,22 +15,22 @@ class LopcommNetconfClient:
def __init__(self): def __init__(self):
log_file = "{{ log_file }}" log_file = "{{ log_file }}"
software_json_log_file = "{{ software_json_log_file }}" software_output_json_log_file = "{{ software_output_json_log_file }}"
self.logger = logging.getLogger('logger') self.logger = logging.getLogger('logger')
self.software_json_logger = logging.getLogger('software_json_logger') self.software_output_json_logger = logging.getLogger('software_output_json_logger')
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)
self.software_json_logger.setLevel(logging.DEBUG) self.software_output_json_logger.setLevel(logging.DEBUG)
handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5) handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5)
self.logger.addHandler(handler) self.logger.addHandler(handler)
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
handler.setFormatter(formatter) handler.setFormatter(formatter)
software_json_handler = RotatingFileHandler(software_json_log_file, maxBytes=100000, backupCount=5) software_output_json_handler = RotatingFileHandler(software_output_json_log_file, maxBytes=100000, backupCount=5)
software_json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}') software_output_json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}')
software_json_handler.setFormatter(software_json_formatter) software_output_json_handler.setFormatter(software_output_json_formatter)
self.software_json_logger.addHandler(software_json_handler) self.software_output_json_logger.addHandler(software_output_json_handler)
if {{ testing }}: if {{ testing }}:
return return
...@@ -88,7 +88,7 @@ if __name__ == '__main__': ...@@ -88,7 +88,7 @@ if __name__ == '__main__':
if reply_xml is not None: if reply_xml is not None:
# Process and log the reply XML as needed # Process and log the reply XML as needed
data_dict xmltodict.parse(reply_xml._raw) data_dict xmltodict.parse(reply_xml._raw)
self.software_json_logger.info('', extra={'data': data_dict})(reply_xml) self.software_output_json_logger.info('', extra={'data': data_dict})(reply_xml)
break break
except Exception as e: except Exception as e:
......
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