def send_message(self, message): """ Sends a message to the connected counterpart web socket :param message: A string containing the message """ if of.common.logging.severity < SEV_INFO: # We cannot use the normal facility here as that would cause recursion print(make_sparse_log_message("Sending message:" + str(message), _category=EC_COMMUNICATION, _severity = SEV_DEBUG, _address=self.address_own, _process_id=self.process_id)) # send() below is implemented by multiple inheritance in the subclass. Ignore "unresolved attribute"-warning. self.send(bytes(json.dumps(message).encode()))
def log_locally(_data, _category, _severity, _process_id_param, _user_id, _occurred_when, _address_param, _node_id, _uid, _pid): global process_id, address if _process_id_param is None: _process_id_param = process_id if _address_param is None: _address_param = address if os.name == "nt": write_to_event_log(make_textual_log_message(_data, _category, _severity, _process_id_param, _user_id, _occurred_when, _address_param, _node_id, _uid, _pid), "Application", _category, _severity) else: _message = make_sparse_log_message(_data, _category, _severity, _process_id_param, _user_id, _occurred_when, _address_param, _node_id, _uid, _pid) try: x_logger.log(msg=_message, level=CRITICAL) except Exception as e: print( make_sparse_log_message("FAILED TO WRITE TO FILE, PRINTING ERROR: "+ str(e) + _message, EC_SERVICE, SEV_ERROR, _process_id_param, _user_id, _occurred_when, _address_param, _node_id, _uid, _pid))
def log_locally(_data, _category, _severity, _process_id_param, _user_id, _occurred_when, _address_param, _node_id, _uid, _pid): global _log_to_database_severity, process_id, _broker_url, _address if _process_id_param is None: _process_id_param = process_id if os.name == "nt": write_to_event_log(make_textual_log_message(_data, _category, _severity, _process_id_param, _user_id, _occurred_when, _address, _node_id, _uid, _pid), "Application", _category, _severity) else: print( make_sparse_log_message(_data, _category, _severity, process_id, _user_id, _occurred_when, _address, _node_id, _uid, _pid))