Skip to content

Commit a389e24

Browse files
committed
Refined utils.log.log() to flush stdout before logging if we're writing log messages to stderr.
- Legacy-Id: 15463
1 parent debaf83 commit a389e24

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

ietf/utils/log.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ def getcaller():
3636
def log(msg):
3737
"Uses syslog by preference. Logs the given calling point and message."
3838
global logfunc
39+
def _flushfunc():
40+
pass
41+
_logfunc = logfunc
3942
if settings.SERVER_MODE == 'test':
4043
return
4144
elif settings.DEBUG == True:
42-
logfunc = debug.say
45+
_logfunc = debug.say
46+
_flushfunc = sys.stdout.flush
4347
if isinstance(msg, unicode):
4448
msg = msg.encode('unicode_escape')
4549
try:
@@ -52,7 +56,8 @@ def log(msg):
5256
where = " in " + func + "()"
5357
except IndexError:
5458
file, line, where = "/<UNKNOWN>", 0, ""
55-
logfunc("ietf%s(%d)%s: %s" % (file, line, where, msg))
59+
_flushfunc()
60+
_logfunc("ietf%s(%d)%s: %s" % (file, line, where, msg))
5661

5762
logger = logging.getLogger('django')
5863

0 commit comments

Comments
 (0)