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 a client hook djust does not ship: dj-hook="LogViewer". The markup renders, but the interaction described above is yours to add — register window.djust.hooks.LogViewer = { mounted() { … } } before client.js loads (see the hooks guide).

Parameters

NameTypeDefault
lineslist | NoneNone
stream_eventstr — the event your server pushes to it''
show_line_numbersboolTrue
auto_scrollboolTrue
filter_levelstr''
wrapboolFalse
max_linesint0
custom_classstr''
**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 2116, 2117, 2118, 2120, 2121, 2123, 2124. Override those rules, or the custom properties they read, in a stylesheet loaded after it.