mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 04:03:55 +00:00
27 lines
714 B
Python
27 lines
714 B
Python
import sys
|
|
from logging import Handler
|
|
|
|
|
|
class FTStdErrStreamHandler(Handler):
|
|
def flush(self):
|
|
"""
|
|
Override Flush behaviour - we keep half of the configured capacity
|
|
otherwise, we have moments with "empty" logs.
|
|
"""
|
|
self.acquire()
|
|
try:
|
|
sys.stderr.flush()
|
|
finally:
|
|
self.release()
|
|
|
|
def emit(self, record):
|
|
try:
|
|
msg = self.format(record)
|
|
# Don't keep a reference to stderr - this can be problematic with progressbars.
|
|
sys.stderr.write(msg + '\n')
|
|
self.flush()
|
|
except RecursionError:
|
|
raise
|
|
except Exception:
|
|
self.handleError(record)
|