Documentation ¶
Index ¶
- Constants
- Variables
- func HitShortcut(event *tcell.EventKey, keybindings ...[]string) bool
- type Key
- type LogEvent
- type LogLevel
- type LogVelocityView
- func (lh *LogVelocityView) AppendLogEvent(event *LogEvent)
- func (lh *LogVelocityView) AutoScale(from, to time.Time)
- func (lh *LogVelocityView) Clear()
- func (lh *LogVelocityView) ClearAnchor()
- func (lh *LogVelocityView) Draw(screen tcell.Screen)
- func (lh *LogVelocityView) GetAnchor() *time.Time
- func (lh *LogVelocityView) GetShowLogLevel() LogLevel
- func (lh *LogVelocityView) ScaleFor(duration time.Duration)
- func (lh *LogVelocityView) SetAnchor(newAnchor time.Time)
- func (lh *LogVelocityView) SetShowLogLevel(logLevel LogLevel)
- type LogView
- func (lv *LogView) AppendEvent(logEvent *LogEvent)
- func (lv *LogView) AppendEvents(events []*LogEvent)
- func (lv *LogView) Clear()
- func (lv *LogView) Draw(screen tcell.Screen)
- func (lv *LogView) EventCount() uint
- func (lv *LogView) FindMatchingEvent(startingEventId string, predicate func(event *LogEvent) bool) *LogEvent
- func (lv *LogView) Focus(_ func(p gui.Primitive))
- func (lv *LogView) GetCurrentEvent() *LogEvent
- func (lv *LogView) GetEventCount() uint
- func (lv *LogView) GetFirstEvent() *LogEvent
- func (lv *LogView) GetHeight() int
- func (lv *LogView) GetMaxEvents() uint
- func (lv *LogView) GetNewEventMatchingRegex() string
- func (lv *LogView) GetSourceClipLength() int
- func (lv *LogView) GetTimestampFormat() string
- func (lv *LogView) GetWidth() int
- func (lv *LogView) HasFocus() bool
- func (lv *LogView) InputHandler() func(event *tcell.EventKey, setFocus func(p gui.Primitive))
- func (lv *LogView) IsConcatenateEventsEnabled() bool
- func (lv *LogView) IsFollowing() bool
- func (lv *LogView) IsHighlightCurrentEventEnabled() bool
- func (lv *LogView) IsHighlightingEnabled() bool
- func (lv *LogView) IsLevelHighlightingEnabled() bool
- func (lv *LogView) IsLineWrapEnabled() bool
- func (lv *LogView) IsShowSource() bool
- func (lv *LogView) IsShowTimestamp() bool
- func (lv *LogView) MouseHandler() ...
- func (lv *LogView) RefreshHighlights()
- func (lv *LogView) ScrollPageDown()
- func (lv *LogView) ScrollPageUp()
- func (lv *LogView) ScrollToBottom()
- func (lv *LogView) ScrollToEventID(eventID string) bool
- func (lv *LogView) ScrollToTimestamp(timestamp time.Time) bool
- func (lv *LogView) ScrollToTop()
- func (lv *LogView) SelectNextEvent()
- func (lv *LogView) SelectPrevEvent()
- func (lv *LogView) SetBorder(_ bool)
- func (lv *LogView) SetConcatenateEvents(enabled bool)
- func (lv *LogView) SetCurrentBgColor(color tcell.Color)
- func (lv *LogView) SetErrorBgColor(bgColor tcell.Color)
- func (lv *LogView) SetEventLimit(limit uint)
- func (lv *LogView) SetFollowing(follow bool)
- func (lv *LogView) SetHighlightCurrentEvent(enabled bool)
- func (lv *LogView) SetHighlightPattern(pattern string)
- func (lv *LogView) SetHighlighting(enable bool)
- func (lv *LogView) SetLevelHighlighting(enabled bool)
- func (lv *LogView) SetLineWrap(enabled bool)
- func (lv *LogView) SetMaxEvents(limit uint)
- func (lv *LogView) SetNewEventMatchingRegex(regex string)
- func (lv *LogView) SetOnCurrentChange(listener OnCurrentChanged)
- func (lv *LogView) SetShowSource(enabled bool)
- func (lv *LogView) SetShowTimestamp(enabled bool)
- func (lv *LogView) SetSourceClipLength(length int)
- func (lv *LogView) SetSourceStyle(style tcell.Style)
- func (lv *LogView) SetTextStyle(style tcell.Style)
- func (lv *LogView) SetTimestampFormat(format string)
- func (lv *LogView) SetTimestampStyle(style tcell.Style)
- func (lv *LogView) SetWarningBgColor(bgColor tcell.Color)
- type OnCurrentChanged
Constants ¶
const ( // LogLevelInfo is default log LogLevelInfo = LogLevel(iota) // LogLevelWarning is the level for warnings LogLevelWarning // LogLevelError is the level for errors LogLevelError // LogLevelAll is used for building histograms only as a placeholder for all log levels LogLevelAll )
Variables ¶
var Keys = Key{ Cancel: []string{"Escape"}, Select: []string{"Enter", "Ctrl+J"}, Select2: []string{"Space"}, MoveUp: []string{"Up"}, MoveUp2: []string{"k"}, MoveDown: []string{"Down"}, MoveDown2: []string{"j"}, MoveLeft: []string{"Left"}, MoveLeft2: []string{"h"}, MoveRight: []string{"Right"}, MoveRight2: []string{"l"}, MoveFirst: []string{"Home", "Ctrl+A"}, MoveFirst2: []string{"g"}, MoveLast: []string{"End", "Ctrl+E"}, MoveLast2: []string{"G"}, MovePreviousField: []string{"Backtab"}, MoveNextField: []string{"Tab"}, MovePreviousPage: []string{"PageUp", "Ctrl+B"}, MoveNextPage: []string{"PageDown", "Ctrl+F"}, ShowContextMenu: []string{"Alt+Enter"}, }
Keys defines the keyboard shortcuts of an application. Secondary shortcuts apply when not focusing a text input.
Functions ¶
func HitShortcut ¶
HitShortcut returns whether the EventKey provided is present in one or more sets of keybindings.
Types ¶
type Key ¶
type Key struct { Cancel []string Select []string Select2 []string MoveUp []string MoveUp2 []string MoveDown []string MoveDown2 []string MoveLeft []string MoveLeft2 []string MoveRight []string MoveRight2 []string MoveFirst []string MoveFirst2 []string MoveLast []string MoveLast2 []string MovePreviousField []string MoveNextField []string MovePreviousPage []string MoveNextPage []string ShowContextMenu []string }
Key defines the keyboard shortcuts of an application. Secondary shortcuts apply when not focusing a text input.
type LogEvent ¶
type LogEvent struct { EventID string Source string Timestamp time.Time Level LogLevel Message string }
LogEvent that can be added to LogView. Contains following fields:
- EventID - a string identifier of the event, used in event handlers, may contain only ASCII characters
- Source - a source that produced the event, may contain only ASCII characters
- Timestamp - an instant when the event was created/ingested
- Level - the severity level of an event. Can be used to highlight errors and warnings
- Message - the event contents
func NewLogEvent ¶
type LogLevel ¶
type LogLevel uint
LogLevel represents the log level LogView recognizes three log levels: Info, Warning and Error Warning and Error events can be highlighted
type LogVelocityView ¶
LogVelocityView is a bar chart to display number of log events per time period
func NewLogVelocityView ¶
func NewLogVelocityView(bucketWidth time.Duration) *LogVelocityView
NewLogVelocityView creates a new log velocity view with a defined bucket time frame
func (*LogVelocityView) AppendLogEvent ¶
func (lh *LogVelocityView) AppendLogEvent(event *LogEvent)
AppendLogEvents adds event to a velocity chart
func (*LogVelocityView) AutoScale ¶ added in v0.1.0
func (lh *LogVelocityView) AutoScale(from, to time.Time)
func (*LogVelocityView) Clear ¶
func (lh *LogVelocityView) Clear()
Clear resets all the statistics. Bucket width and anchor do not change
func (*LogVelocityView) ClearAnchor ¶
func (lh *LogVelocityView) ClearAnchor()
ClearAnchor removes the max time for the time axis. Max time will be equal to the current time
func (*LogVelocityView) Draw ¶
func (lh *LogVelocityView) Draw(screen tcell.Screen)
Draw draws this primitive onto the screen.
func (*LogVelocityView) GetAnchor ¶
func (lh *LogVelocityView) GetAnchor() *time.Time
func (*LogVelocityView) GetShowLogLevel ¶
func (lh *LogVelocityView) GetShowLogLevel() LogLevel
GetShowLogLevel returns the log level of events that are be displayed in the velocity view
func (*LogVelocityView) ScaleFor ¶ added in v0.1.0
func (lh *LogVelocityView) ScaleFor(duration time.Duration)
func (*LogVelocityView) SetAnchor ¶
func (lh *LogVelocityView) SetAnchor(newAnchor time.Time)
SetAnchor sets the max time for the time axis
func (*LogVelocityView) SetShowLogLevel ¶
func (lh *LogVelocityView) SetShowLogLevel(logLevel LogLevel)
SetShowLogLevel sets the log level of events that should be displayed in the velocity view
Supported values are:
LogLevelInfo - show all events but warning and errors
LogLevelWarning
LogLevelError
LogLevelAll - show all events
type LogView ¶
LogView is a Box that displays log events
LogView doesn't have border or scroll bars to allow easier copy-paste of events.
func (*LogView) AppendEvent ¶
AppendEvent appends an event to the log view If possible use AppendEvents to add multiple events at once
func (*LogView) AppendEvents ¶
AppendEvents appends multiple events in a single batch improving performance
func (*LogView) Draw ¶
func (lv *LogView) Draw(screen tcell.Screen)
Draw draws this primitive onto the screen.
func (*LogView) EventCount ¶
EventCount returns the number of log events in the log view
func (*LogView) FindMatchingEvent ¶ added in v0.0.2
func (lv *LogView) FindMatchingEvent(startingEventId string, predicate func(event *LogEvent) bool) *LogEvent
FindMatchingEvent searches for a event that matches a given predicate First event to be matched is the one with event id equal to startingEventId. If the startingEventId is an empty string, the search will start from the first event in the log view.
If no such event can be found it will return nil
func (*LogView) GetCurrentEvent ¶
GetCurrentEvent returns the currently selected event
func (*LogView) GetEventCount ¶
GetEventCount returns number of events in the log view
func (*LogView) GetFirstEvent ¶ added in v0.0.2
GetFirstEvent returns the first event in the log view
func (*LogView) GetMaxEvents ¶
GetMaxEvents returns a maximum number of events that log view will hold
func (*LogView) GetNewEventMatchingRegex ¶ added in v0.0.2
GetNewEventMatchingRegex gets the regular expression used for detecting continuation events.
func (*LogView) GetSourceClipLength ¶
GetSourceClipLength returns the current maximum length of event source that would be displayed
func (*LogView) GetTimestampFormat ¶
GetTimestampFormat returns the format used to display timestamps
func (*LogView) InputHandler ¶
InputHandler returns the handler for this primitive.
func (*LogView) IsConcatenateEventsEnabled ¶
IsConcatenateEventsEnabled returns the status of event concatenation
func (*LogView) IsFollowing ¶
IsFollowing returns whether the following mode is enabled. Following mode automatically scrolls log view up as new events are appended. Last event is always in the view.
func (*LogView) IsHighlightCurrentEventEnabled ¶ added in v0.0.2
IsHighlightCurrentEventEnabled returns the status background color highlighting for currently selected event
func (*LogView) IsHighlightingEnabled ¶ added in v0.0.2
IsHighlightingEnabled returns the status of event message highlighting
func (*LogView) IsLevelHighlightingEnabled ¶ added in v0.0.2
IsLevelHighlightingEnabled returns the status of background color highlighting for events based on severity level
func (*LogView) IsLineWrapEnabled ¶
IsLineWrapEnabled returns the current status of line wrap
func (*LogView) IsShowSource ¶ added in v0.0.2
IsShowSource returns whether the showing of event source is enabled
func (*LogView) IsShowTimestamp ¶ added in v0.0.2
IsShowTimestamp returns whether the showing of event source is enabled
func (*LogView) MouseHandler ¶
func (lv *LogView) MouseHandler() func(action gui.MouseAction, event *tcell.EventMouse, setFocus func(p gui.Primitive)) (consumed bool, capture gui.Primitive)
MouseHandler returns the mouse handler for this primitive.
func (*LogView) RefreshHighlights ¶
func (lv *LogView) RefreshHighlights()
RefreshHighlights forces recalculation of highlight patterns for all events in the log view. LogView calculates highlight spans once for each event when the event is appended. Any changes in highlighting will not be applied to the events that are already in the log view. To apply changes to all the events call this function. Warning: this might be a rather expensive operation
func (*LogView) ScrollPageDown ¶
func (lv *LogView) ScrollPageDown()
ScrollPageDown scrolls the log view one screen down
This will enable auto follow if the last line has been reached
func (*LogView) ScrollPageUp ¶
func (lv *LogView) ScrollPageUp()
ScrollPageUp scrolls the log view one screen up
This does not disables following.
func (*LogView) ScrollToBottom ¶
func (lv *LogView) ScrollToBottom()
ScrollToBottom scrolls the log view to the last event
This does not automatically enables following. User SetFollowing function to enable it
func (*LogView) ScrollToEventID ¶
ScrollToEventID scrolls to the first event with a matching eventID If no such event is found it will not scroll and return false.
Current event will be updated to the found event
func (*LogView) ScrollToTimestamp ¶
ScrollToTimestamp scrolls to the first event with a timestamp equal to or greater than given. If no event satisfies that condition it will not scroll and return false.
Current event will be updated to the found event
func (*LogView) ScrollToTop ¶
func (lv *LogView) ScrollToTop()
ScrollToTop scrolls the log view to the first event
This does not automatically enables following. User SetFollowing function to enable it
func (*LogView) SelectNextEvent ¶ added in v0.1.0
func (lv *LogView) SelectNextEvent()
SelectNextEvent selects the next event in the log view
func (*LogView) SelectPrevEvent ¶ added in v0.1.0
func (lv *LogView) SelectPrevEvent()
SelectPrevEvent selects the previous event in the log view
func (*LogView) SetConcatenateEvents ¶
SetConcatenateEvents enables/disables event concatenation
Events with a message that do not match regular expression set by SetNewEventMatcher are appended to the previous event
func (*LogView) SetCurrentBgColor ¶
func (lv *LogView) SetCurrentBgColor(color tcell.Color)
SetCurrentBgColor sets the background color to highlight currently selected event
func (*LogView) SetErrorBgColor ¶
func (lv *LogView) SetErrorBgColor(bgColor tcell.Color)
SetErrorColor sets the background color for events with level == LogLevelError. Event level highlighting can be turned on and off with SetLevelHighlighting function.
Changing error color will do nothing to the events that are already in the log view. To update highlighting of all events use RefreshHighlights. Be warned: this is an expensive operation
func (*LogView) SetEventLimit ¶
SetEventLimit sets the limit to number of log event held by log view.
To disable limit set it to zero.
func (*LogView) SetFollowing ¶
SetFollowing enables/disables following mode. Following mode automatically scrolls log view up as new events are appended. Last event is always in the view
Enabling following will automatically scroll to the last event
func (*LogView) SetHighlightCurrentEvent ¶
SetHighlightCurrentEvent enables background color highlighting for currently selected event
func (*LogView) SetHighlightPattern ¶
SetHighlightPattern sets new regular expression pattern to find spans that need to be highlighted setting this to nil disables highlighting.
pattern is a regular expression where each matching named capturing group can be highlighted with a different color. Colors for any given group name can be set with SetHighlightColor, SetHighlightColorFg, SetHighlightColorBg
Note: Updating pattern doesn't changes highlighting for previously appended events Call RefreshHighlights() to force updating highlighting for all events in the log view.
func (*LogView) SetHighlighting ¶
SetHighlighting enables/disables event message highlighting according to the pattern set by SetHighlightPattern.
Events appended when this setting was disabled will not be highlighted until RefreshHighlights function is called.
func (*LogView) SetLevelHighlighting ¶
SetLevelHighlighting enables background color highlighting for events based on severity level
func (*LogView) SetLineWrap ¶
SetLineWrap enables/disables the line wrap. Disabling line wrap may increase performance
func (*LogView) SetMaxEvents ¶
SetMaxEvents sets a maximum number of events that log view will hold
func (*LogView) SetNewEventMatchingRegex ¶ added in v0.0.2
SetNewEventMatcher sets the regular expression to use for detecting continuation events.
If event message matches provided regular expression it is treated as a new event, otherwise it is appended to a previous line. All attributes of appended event are discarded.
If line wrapping is enabled, event will be split into original lines ¶
For example typical Java exception looks like IllegalArgumentException: No nulls please
caused by NullPointerException at org.some.java.package.Class at org.another.java.package
Each line might be a new log event, but it makes sense to treat whole stack trace as as a single event.
func (*LogView) SetOnCurrentChange ¶
func (lv *LogView) SetOnCurrentChange(listener OnCurrentChanged)
SetOnCurrentChange sets a listener that will be called every time the current event is changed
If current event highlighting is disabled, listener will not be called.
func (*LogView) SetShowSource ¶
SetShowSource enables/disables the displaying of event source
Event Source is displayed to the left of the actual event message with style defined by SetSourceStyle and is clipped to the length set by SetSourceClipLength (6 characters is the default)
func (*LogView) SetShowTimestamp ¶
SetShowTimestamp enables/disables the displaying of event timestamp
Event timestamp is displayed to the left of the actual event message with the format defined by SetTimestampFormat
func (*LogView) SetSourceClipLength ¶
SetSourceClipLength sets the maximum length of event source that would be displayed if SetShowSource is on
func (*LogView) SetSourceStyle ¶
func (lv *LogView) SetSourceStyle(style tcell.Style)
SetSourceStyle sets the style for displaying event source
func (*LogView) SetTextStyle ¶
func (lv *LogView) SetTextStyle(style tcell.Style)
SetTextStyle sets the default style for the log messages
func (*LogView) SetTimestampFormat ¶
SetTimestampFormat sets the format for displaying the event timestamp.
Default is 15:04:05.000
func (*LogView) SetTimestampStyle ¶
func (lv *LogView) SetTimestampStyle(style tcell.Style)
SetTimestampStyle sets the style for displaying event timestamp
func (*LogView) SetWarningBgColor ¶
func (lv *LogView) SetWarningBgColor(bgColor tcell.Color)
SetWarningColor sets the background color for events with level == LogLevelWarning. Event level highlighting can be turned on and off with SetLevelHighlighting function.
Changing warning color will do nothing to the events that are already in the log view. To update highlighting of all events use RefreshHighlights. Be warned: this is an expensive operation
type OnCurrentChanged ¶
type OnCurrentChanged func(current *LogEvent)
OnCurrentChanged is an event time that is fired when current log event is changed