1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

Write log as binary file in Python 3

Fixes

      File "bin/srv.py", line 101, in log_query
        my_file.write(log_entry.encode('utf-8')+"\n")
    TypeError: can't concat str to bytes
This commit is contained in:
Anatoli Babenia
2020-07-29 14:55:08 +03:00
parent aae40ae3a8
commit fbe5414e9c
+3 -3
View File
@@ -96,9 +96,9 @@ def log_query(ip_addr, found, topic, user_agent):
"""
Log processed query and some internal data
"""
log_entry = "%s %s %s %s" % (ip_addr, found, topic, user_agent)
with open(CONFIG["path.log.queries"], 'a') as my_file:
my_file.write(log_entry.encode('utf-8')+"\n")
log_entry = "%s %s %s %s\n" % (ip_addr, found, topic, user_agent)
with open(CONFIG["path.log.queries"], 'ab') as my_file:
my_file.write(log_entry.encode('utf-8'))
def get_request_ip(req):
"""