Skip to content

Commit

Permalink
fixed colored log prefix does not skip ws writer
Browse files Browse the repository at this point in the history
  • Loading branch information
visualDust committed Nov 25, 2023
1 parent 6cc0569 commit c7b46f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 5 additions & 5 deletions neetbox/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def ok(self, *message, flag="OK"):
self.log(
*message,
prefix=f"[{colored_text(flag, 'green')}]",
skip_writers=["file"],
skip_writers=["file", "ws"],
traceback=3,
)
self.log(*message, prefix=flag, skip_writers=["stdout"], traceback=3)
Expand All @@ -139,7 +139,7 @@ def debug(self, *message, flag="DEBUG"):
self.log(
*message,
prefix=f"[{colored_text(flag, 'cyan')}]",
skip_writers=["file"],
skip_writers=["file", "ws"],
traceback=3,
)
self.log(*message, prefix=flag, skip_writers=["stdout"], traceback=3)
Expand All @@ -150,7 +150,7 @@ def info(self, *message, flag="INFO"):
self.log(
*message,
prefix=f"[{colored_text(flag, 'white')}]",
skip_writers=["file"],
skip_writers=["file", "ws"],
traceback=3,
)
self.log(*message, prefix=flag, skip_writers=["stdout"], traceback=3)
Expand All @@ -161,7 +161,7 @@ def warn(self, *message, flag="WARNING"):
self.log(
*message,
prefix=f"[{colored_text(flag, 'yellow')}]",
skip_writers=["file"],
skip_writers=["file", "ws"],
traceback=3,
)
self.log(*message, prefix=flag, skip_writers=["stdout"], traceback=3)
Expand All @@ -174,7 +174,7 @@ def err(self, err, flag="ERROR", reraise=False):
self.log(
str(err),
prefix=f"[{colored_text(flag,'red')}]",
skip_writers=["file"],
skip_writers=["file", "ws"],
traceback=3,
)
self.log(str(err), prefix=flag, skip_writers=["stdout"], traceback=3)
Expand Down
9 changes: 9 additions & 0 deletions tests/client/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def print_to_console(metrix):
logger.log(f"metrix from train: {metrix}")


@watch("log-some-prefix", freq=50)
def log_with_some_prefix():
logger.ok("some ok")
logger.info("some info")
logger.debug("some debug")
logger.warn("some warn")
logger.err("some error")


@action(name="action-1")
def action_1(text):
logger.log(f"action 1 triggered. text = {text}")
Expand Down

0 comments on commit c7b46f8

Please sign in to comment.