Log Viewer

Monospace streaming log display with level coloring.

python 9 params

Preview

1[info] server started
2[info] connected to database
3[warn] slow query: 1.2s
Arguments
log_viewer(lines=['[info] server started', '[info] connected to database', '[warn] slow query: 1.2s'])

Usage

views.py
python
from djust import LiveView
from djust.components import LogViewer


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = LogViewer(lines=['[info] server started', '[info] connected to database', '[warn] slow query: 1.2s'])
my_template.html
django
{{ component }}

Needs its script on the page: <script src="{% static 'djust_components/log-viewer.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

Parameters

NameTypeDefaultDescription
lineslist | NoneNonelist of log line strings
stream_eventstr — the event your server pushes to it''djust event for receiving new log lines
show_line_numbersboolTrueshow line numbers (default True)
auto_scrollboolTrueauto-scroll to bottom on new lines (default True)
filter_levelstr''filter to specific level (info/warn/error/debug)
wrapboolFalsewrap long lines (default False)
max_linesint0maximum lines to display (0 = unlimited)
custom_classstr''additional CSS classes
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state——
Source & styles
FilePathNotes
moduledjust.components.components.log_viewerSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 7 of this component's classes at line 2172, 2173, 2174, 2176, 2177, 2179, 2180. Override those rules, or the custom properties they read, in a stylesheet loaded after it.