Log a timestamp as well when printing error messages from python

This commit is contained in:
Kovid Goyal
2018-03-04 10:44:28 +05:30
parent fd6159c0b4
commit ed75ad0d41
6 changed files with 37 additions and 62 deletions
+11 -2
View File
@@ -3,6 +3,7 @@
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import atexit
import datetime
import errno
import fcntl
import math
@@ -19,8 +20,7 @@ from time import monotonic
from .constants import appname, is_macos, is_wayland
from .fast_data_types import (
GLSL_VERSION, redirect_std_streams, x11_display,
x11_window_id
GLSL_VERSION, redirect_std_streams, x11_display, x11_window_id
)
from .rgb import Color, to_color
@@ -40,6 +40,15 @@ def safe_print(*a, **k):
pass
def log_error(*a, **k):
try:
msg = k.get('sep', ' ').join(map(str, a)) + k.get('end', '\n')
msg = datetime.datetime.now().strftime('[%j %H:%M:%S.%f] ') + msg
sys.stderr.write(msg)
except Exception:
pass
def ceil_int(x):
return int(math.ceil(x))