LogView
A LogView is a log in a ListView: a toggle for each kind with its count, a text filter, Follow, Clear, and the whole message and stack trace of the selected entry in a vertical SplitPanel under the list. A ConsoleView is a LogView with a command line under it.


<UIToolbox.LogView capture-unity-log="true" max-items="500" />
log.Add(LogEntryKind.Warning, "Low memory", stackTrace);
log.Add(LogEntryKind.Command, "> spawn orc"); // shows with any kinds
// shows the new entries now
log.Refresh();
| Member | Description |
|---|---|
Add(kind, message, stackTrace) |
Adds an entry and returns it. Add(message, stackTrace, LogType) takes a Unity log message; an exception and an assert count as errors. Call it on the main thread. |
Clear() |
Removes all entries and shows the empty list at once. |
Entries, Shown |
All entries, and the entries that the list shows after the filters. |
Count(kind) |
The number of entries of a kind. |
MaxItems (max-items) |
The most entries kept (1000), at least 1. The oldest go first. |
CaptureUnityLog (capture-unity-log) |
True shows the messages of Application.logMessageReceivedThreaded while the view is on a panel. A worker thread message waits for the next refresh tick. |
Follow (follow) |
True (the default) scrolls to each new entry. |
ShowCopyButton (show-copy-button) |
On (the default): the bar has a Copy button. |
Copy() |
Puts CopyText on the system clipboard and raises Copied with the text. The Copy button calls it. |
CopyText |
The text for the clipboard. With a selected entry: its message and stack trace. With no selection: one line for each shown entry, with its time, its kind and its message. |
ShowClearButton (show-clear-button) |
On (the default): the filter box shows a "x" button while it has text, and a click clears the text. Escape in the filter box also clears the text. See Clear button. |
Refresh() |
Filters the entries again and shows them. The selection stays when its entry still shows. |
Changed |
Raised after entries were added or cleared. |
KindToggle(kind), FilterField, FollowToggle, List, Detail |
The parts, for code that changes them. |
- The list shows new entries at most every 100 ms, so a burst of messages does one rebuild.
- In the UI Builder, a view without entries shows a sample message, warning and error in a dashed outline. The sample does not show in Play mode or in a build, and the UI Builder does not save it to the UXML file.
- A
LogEntryKind.Commandentry shows with any kinds; the Log, Warning and Error toggles filter the other kinds. - The texts come from
ToolboxText(LOG,WARNING,ERROR,FILTER,FOLLOW,FOLLOW_TOOLTIP,SELECT_LOG_ENTRY,CLEAR). - The row has a dot for the kind, the time and the first line of the message. The classes are
tb-log-view__rowwith--log,--warning,--erroror--command, and__row-dot,__row-timeand__row-message.
Styling
| Class | Element |
|---|---|
tb-log-view |
The view (grows). |
tb-log-view__bar |
The row of the kind toggles, the filter, Follow, Copy and Clear. A bar too narrow for them wraps. |
tb-log-view__kind |
A kind toggle. Modifiers: --log, --warning, --error. |
tb-log-view__filter |
The text filter. It takes the width that the other parts leave, and is at least 64 px wide. |
tb-log-view__split |
The vertical SplitPanel of the list and the detail, with a --tb-color-border border. |
tb-log-view__list |
The native ListView, on --tb-color-surface-alt. |
tb-log-view__row |
A row. Modifiers: --log, --warning (--tb-color-warning text), --error (--tb-color-text-danger text), --command (bold). |
tb-log-view__row-dot |
The dot of the kind: --tb-color-text-muted, the warning, the danger or the accent color. |
tb-log-view__row-time |
The time, --tb-color-text-muted, right-aligned. |
tb-log-view__row-message |
The first line of the message (ellipsis). |
tb-log-view__detail-pane |
The ScrollView of the detail, under the list. It is at least 32 px high, so a message of one line shows with no scroll bar, also when the split is low. |
tb-log-view__detail |
The whole message and stack trace of the selected entry (wraps, selectable). |
The LogViewDemo scene shows a game log with a filter for each kind and a stack trace, a combat log with a line limit and its own colors, and the Unity log of the game.