mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-03-06 15:07:31 +08:00
enhanced logging and error reporting system
This commit is contained in:
@@ -4,12 +4,11 @@
|
||||
Creator: Video2X Bidirectional Logger
|
||||
Author: K4YT3X
|
||||
Date Created: June 4, 2020
|
||||
Last Modified: July 17, 2020
|
||||
Last Modified: September 13, 2020
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
import _io
|
||||
import pathlib
|
||||
|
||||
|
||||
class BiLogger(object):
|
||||
@@ -19,15 +18,15 @@ class BiLogger(object):
|
||||
Original code from: https://stackoverflow.com/a/14906787
|
||||
"""
|
||||
|
||||
def __init__(self, terminal: _io.TextIOWrapper, logfile: pathlib.Path):
|
||||
def __init__(self, terminal: _io.TextIOWrapper, log_file: _io.BufferedRandom):
|
||||
""" initialize BiLogger
|
||||
|
||||
Args:
|
||||
terminal (_io.TextIOWrapper): original terminal IO wrapper
|
||||
logfile (pathlib.Path): target log file path object
|
||||
logfile (_io.BufferedRandom): log file wrapper
|
||||
"""
|
||||
self.terminal = terminal
|
||||
self.log = logfile.open(mode='a+', encoding='utf-8')
|
||||
self.log_file = log_file
|
||||
|
||||
def write(self, message: str):
|
||||
""" write message to original terminal output and log file
|
||||
@@ -37,8 +36,8 @@ class BiLogger(object):
|
||||
"""
|
||||
self.terminal.write(message)
|
||||
self.terminal.flush()
|
||||
self.log.write(message)
|
||||
self.log.flush()
|
||||
self.log_file.write(message)
|
||||
self.log_file.flush()
|
||||
|
||||
def flush(self):
|
||||
""" flush logger (for compability only)
|
||||
|
||||
Reference in New Issue
Block a user