Log Viewer
Monospace streaming log display with level coloring.
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
| Name | Type | Default |
|---|---|---|
| lines | list | None | None |
| stream_event | str — the event your server pushes to it | '' |
| show_line_numbers | bool | True |
| auto_scroll | bool | True |
| filter_level | str | '' |
| wrap | bool | False |
| max_lines | int | 0 |
| custom_class | str | '' |
| **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
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.log_viewer | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |