Commit d9e9325d authored by Daniele Venzano's avatar Daniele Venzano

Handle logs containing utf-8 characters

parent 31ca0b75
......@@ -53,10 +53,11 @@ class GELFUDPHandler(socketserver.DatagramRequestHandler):
log_file_path = os.path.join(get_conf().service_logs_base_path, get_conf().deployment_name, str(execution_id), service_name + '.txt')
if not os.path.exists(log_file_path):
os.makedirs(os.path.join(get_conf().service_logs_base_path, get_conf().deployment_name, str(execution_id)), exist_ok=True)
open(log_file_path, 'w').write('ZOE HEADER: log file for service {} running on host {}\n'.format(service_name, host))
open(log_file_path, 'wb').write('ZOE HEADER: log file for service {} running on host {}\n'.format(service_name, host).encode('utf-8'))
with open(log_file_path, 'a') as logfile:
logfile.write(timestamp + ' ' + message.encode('utf-8') + '\n')
with open(log_file_path, 'ab') as logfile:
logline = timestamp + ' ' + message + '\n'
logfile.write(logline.encode('utf-8'))
class ZoeLoggerUDPServer(socketserver.UDPServer):
......
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