add use stderr option for stdio output stream
This commit is contained in:
parent
880669b050
commit
87b2e3b00c
@ -52,6 +52,7 @@ class StdioOutputStream(BaseOutputStream):
|
||||
|
||||
level: int = LogLevel.info
|
||||
formatter: BaseFormatter = StdFormatter()
|
||||
use_stderr: bool = True
|
||||
|
||||
def write_stdout(self, message: LogMessage) -> None:
|
||||
if not self.enable:
|
||||
@ -66,7 +67,10 @@ class StdioOutputStream(BaseOutputStream):
|
||||
return None
|
||||
if message.level < self.level:
|
||||
return None
|
||||
if self.use_stderr:
|
||||
print(self.formatter.format_message(message), end='', flush=message.flush, file=sys.stderr)
|
||||
else:
|
||||
print(self.formatter.format_message(message), end='', flush=message.flush)
|
||||
return None
|
||||
|
||||
def flush(self) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user