From d928ffc8df61fb8887043473115c206b0fc5a517 Mon Sep 17 00:00:00 2001 From: Eriks Karls Date: Thu, 5 Mar 2020 13:05:37 +0200 Subject: [PATCH] log message formatting --- erepublik/__init__.py | 2 +- erepublik/utils.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/erepublik/__init__.py b/erepublik/__init__.py index 7394703..0300dc3 100644 --- a/erepublik/__init__.py +++ b/erepublik/__init__.py @@ -5,7 +5,7 @@ __author__ = """Eriks Karls""" __email__ = 'eriks@72.lv' __version__ = '0.20.0' -__commit_id__ = "d4a3719" +__commit_id__ = "260344b" from erepublik import classes, utils from erepublik.citizen import Citizen diff --git a/erepublik/utils.py b/erepublik/utils.py index 1ead306..0e95e5f 100644 --- a/erepublik/utils.py +++ b/erepublik/utils.py @@ -188,7 +188,8 @@ silent_sleep = time.sleep def _write_log(msg, timestamp: bool = True, should_print: bool = False): erep_time_now = now() - txt = textwrap.fill("[{}] {}".format(erep_time_now.strftime('%F %T'), msg) if timestamp else msg, 120) + txt = "[{}] {}".format(erep_time_now.strftime('%F %T'), msg) if timestamp else msg + txt = "\n".join(["\n".join(textwrap.wrap(line, 120)) for line in txt.splitlines()]) if not os.path.isdir('log'): os.mkdir('log') with open("log/%s.log" % erep_time_now.strftime('%F'), 'a', encoding="utf-8") as f: