Skip to content

Commit

Permalink
All tabs scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Nov 4, 2024
1 parent 8e343a6 commit 4d5db0f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tardis/io/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ def __init__(self):
self.logger = logging.getLogger("tardis")

def _create_output_widget(self, height="300px"):
return Output(layout=Layout(height=height, overflow_y="auto"))
layout = Layout(
height=height,
max_height=height,
min_height="100px",
overflow_y="auto",
overflow_x="auto",
border="1px solid #ddd",
width="100%",
display="block"
)
return Output(layout=layout)

def configure_logging(self, log_level, tardis_config, specific_log_level=None):
if "debug" in tardis_config:
Expand Down Expand Up @@ -118,17 +128,20 @@ def _configure_handlers(self, widget_handler):

def _create_and_display_tabs(self):
"""Create and display the logging tabs."""
tab = Tab(children=[
self.log_outputs[key] for key in
["WARNING/ERROR", "INFO", "DEBUG", "ALL"]
])
tab = Tab(
children=[self.log_outputs[key] for key in ["WARNING/ERROR", "INFO", "DEBUG", "ALL"]],
layout=Layout(
width="100%",
min_height="350px", # Allow space for tab header + content
overflow_y="visible"
)
)

for i, title in enumerate(["WARNING/ERROR", "INFO", "DEBUG", "ALL"]):
tab.set_title(i, title)

display(tab)


class LoggingHandler(logging.Handler):
def __init__(self, log_outputs, colors):
super().__init__()
Expand Down Expand Up @@ -161,7 +174,7 @@ def _format_html_output(self, log_entry, record):

def _display_log(self, level, html_output):
"""Display log message in appropriate outputs."""
html_wrapped = f"<pre style='white-space: pre-wrap; word-wrap: break-word;'>{html_output}</pre>"
html_wrapped = f"<pre style='white-space: pre-wrap; word-wrap: break-word; margin: 0;'>{html_output}</pre>"

level_to_output = {
logging.WARNING: "WARNING/ERROR",
Expand Down Expand Up @@ -192,4 +205,4 @@ def logging_state(log_level, tardis_config, specific_log_level=None):
"""Configure logging state for TARDIS."""
logger = TardisLogger()
logger.configure_logging(log_level, tardis_config, specific_log_level)
logger.setup_widget_logging()
logger.setup_widget_logging()

0 comments on commit 4d5db0f

Please sign in to comment.