Skip to content

Commit

Permalink
Replace panel.pane.HTML with panel Feed
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Dec 6, 2024
1 parent d099de3 commit 725f7a3
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tardis/io/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ def get_environment():
return 'standard'

def create_output_widget(height=300):
return pn.pane.HTML(
"",
return pn.Feed(
height=height,
styles={
'overflow-y': 'auto',
'overflow-x': 'auto',
'border': '1px solid #ddd',
'width': '100%',
'font-family': 'monospace',
'padding': '8px',
'background-color': 'white'
}
},
load_buffer=1_000_000,
view_latest=True
)

log_outputs = {
Expand Down Expand Up @@ -127,25 +126,23 @@ def _format_html_output(self, log_entry, record):
return log_entry

def _emit_to_widget(self, level, html_output):
"""Handles the widget updates synchronously"""
"""Handles the widget updates using Feed component"""
level_to_output = {
logging.WARNING: "WARNING/ERROR",
logging.ERROR: "WARNING/ERROR",
logging.INFO: "INFO",
logging.DEBUG: "DEBUG"
}

html_wrapped = f"<div style='margin: 0;'>{html_output}</div>"
html_wrapped = pn.pane.HTML(f"<div style='margin: 0;'>{html_output}</div>")

# Update specific level output
output_key = level_to_output.get(level)
if output_key:
current = self.log_outputs[output_key].object or ""
self.log_outputs[output_key].object = current + "\n" + html_wrapped if current else html_wrapped
self.log_outputs[output_key].append(html_wrapped)

# Update ALL output
current_all = self.log_outputs["ALL"].object or ""
self.log_outputs["ALL"].object = current_all + "\n" + html_wrapped if current_all else html_wrapped
self.log_outputs["ALL"].append(html_wrapped)

# Update Jupyter display if in jupyter environment
if self.environment == 'jupyter':
Expand Down

0 comments on commit 725f7a3

Please sign in to comment.