logging - Why time.sleep() breaks syslog-ng in Python -
logging - Why time.sleep() breaks syslog-ng in Python -
i have been trying log script output syslog-ng, however, if utilize time.sleep() function in code, breaks syslog-ng , stops logging output of script.
here details.
// samplescript.py import time while true: print "hello world" time.sleep(5)
i utilize pipe it's output syslog-ng, , utilize unix logger tool, i'm calling script this;
$ python sampleoutput.py | logger
this not generating output log file. code simple, , working.
by way, don't thing wrong syslog-ng conf file, since if utilize code below, works expected.
// samplescript.py while true: print "hello world"
q: why time.sleep() breaking syslog-ng? there equivalence sleep() function might utilize on code?
thanks in advance.
you need flush buffered stdout-stream:
import sys sys.stdout.flush()
how flush output of python print?
python logging sleep syslog
Comments
Post a Comment