#
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. The Code and logs example (CodeDemo) uses it in three tabs: a console, a combat log and a debug console with the Unity log.
<UIToolbox.LogView capture-unity-log="true" max-entries="500" />
log.Add(LogEntryKind.Warning, "Low memory", stackTrace);
log.Add(LogEntryKind.Command, "> spawn orc"); // shows with any kinds
log.Refresh(); // shows the new entries now
| 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. |
MaxEntries (max-entries) |
The most entries kept (1000). 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.Command entry 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__row with --log, --warning, --error or --command, and __row-dot, __row-time and __row-message.
#Styling
| Class |
Element |
tb-log-view |
The view (grows). |
tb-log-view__bar |
The row of the kind toggles, the filter, Follow and Clear. |
tb-log-view__kind |
A kind toggle. Modifiers: --log, --warning, --error. |
tb-log-view__filter |
The text filter (grows). |
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-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 |
The whole message and stack trace of the selected entry (wraps, selectable). |