Skip to content

Commit a5f21c5

Browse files
rich formatting
1 parent 277e16c commit a5f21c5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

keras_remote/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,31 @@
66
os.environ.setdefault("GRPC_ENABLE_FORK_SUPPORT", "0")
77

88
import logging as python_logging
9+
import os
910

1011
from absl import logging
12+
from rich.console import Console
13+
from rich.logging import RichHandler
1114

1215
from keras_remote.core.core import run as run
1316
from keras_remote.data import Data as Data
1417

1518
logging.use_absl_handler()
1619

17-
# Remove absl verbose prefixes (e.g. I0310... execution.py:297])
18-
logging.get_absl_handler().setFormatter(python_logging.Formatter("%(message)s"))
20+
# Use rich to format the absl logs, making them slightly dimmed and links clickable
21+
console = Console(stderr=True)
22+
rich_handler = RichHandler(
23+
console=console,
24+
show_time=False,
25+
show_path=False,
26+
show_level=False,
27+
markup=True,
28+
)
29+
rich_handler.setFormatter(python_logging.Formatter("[dim]%(message)s[/dim]"))
30+
31+
absl_logger = logging.get_absl_logger()
32+
absl_logger.handlers = [rich_handler]
33+
absl_logger.propagate = False
1934

2035
# Default to INFO if the user is running a script outside of absl.app.run()
2136
# This ensures that operations like container building and job status are visible.

0 commit comments

Comments
 (0)