Redirect logger to stderr.
This commit is contained in:
parent
627c4aa4f0
commit
07a10f192d
|
@ -1,3 +1,4 @@
|
|||
import sys
|
||||
import osdk.vt100 as vt100
|
||||
|
||||
|
||||
|
@ -8,10 +9,13 @@ class Logger:
|
|||
self.name = name
|
||||
|
||||
def log(self, message: str):
|
||||
print(f"{vt100.CYAN}[{self.name}]{vt100.RESET} {message}")
|
||||
print(
|
||||
f"{vt100.CYAN}[{self.name}]{vt100.RESET} {message}", file=sys.stderr)
|
||||
|
||||
def warn(self, message: str):
|
||||
print(f"{vt100.YELLOW}[{self.name}]{vt100.RESET} {message}")
|
||||
print(
|
||||
f"{vt100.YELLOW}[{self.name}]{vt100.RESET} {message}", file=sys.stderr)
|
||||
|
||||
def error(self, message: str):
|
||||
print(f"{vt100.RED}[{self.name}]{vt100.RESET} {message}")
|
||||
print(
|
||||
f"{vt100.RED}[{self.name}]{vt100.RESET} {message}", file=sys.stderr)
|
||||
|
|
|
@ -28,13 +28,13 @@ def title(text: str):
|
|||
print(f"{LIGHT_WHITE}{text}{RESET}:")
|
||||
|
||||
|
||||
def wordwrap(text: str, width: int = 60) -> str:
|
||||
def wordwrap(text: str, width: int = 60, newline="\n") -> str:
|
||||
result = ""
|
||||
curr = 0
|
||||
|
||||
for c in text:
|
||||
if c == " " and curr > width:
|
||||
result += "\n"
|
||||
result += newline
|
||||
curr = 0
|
||||
else:
|
||||
result += c
|
||||
|
|
Loading…
Reference in a new issue