Skip to content
Snippets Groups Projects
Select Git revision
  • 7dfbf8ff699499e2ce90501c6948ddf2e4d20109
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

drng.go

Blame
  • ui_log_entry.go 2.31 KiB
    package statusscreen
    
    import (
    	"fmt"
    
    	"github.com/gdamore/tcell"
    	"github.com/iotaledger/goshimmer/packages/node"
    	"github.com/rivo/tview"
    )
    
    type UILogEntry struct {
    	Primitive         *tview.Grid
    	TimeContainer     *tview.TextView
    	MessageContainer  *tview.TextView
    	LogLevelContainer *tview.TextView
    }
    
    func NewUILogEntry(message StatusMessage) *UILogEntry {
    	logEntry := &UILogEntry{
    		Primitive:         tview.NewGrid(),
    		TimeContainer:     tview.NewTextView(),
    		MessageContainer:  tview.NewTextView(),
    		LogLevelContainer: tview.NewTextView(),
    	}
    
    	logEntry.TimeContainer.SetBackgroundColor(tcell.ColorWhite)
    	logEntry.TimeContainer.SetTextColor(tcell.ColorBlack)
    	logEntry.TimeContainer.SetDynamicColors(true)
    
    	logEntry.MessageContainer.SetBackgroundColor(tcell.ColorWhite)
    	logEntry.MessageContainer.SetTextColor(tcell.ColorBlack)
    	logEntry.MessageContainer.SetDynamicColors(true)
    
    	logEntry.LogLevelContainer.SetBackgroundColor(tcell.ColorWhite)
    	logEntry.LogLevelContainer.SetTextColor(tcell.ColorBlack)
    	logEntry.LogLevelContainer.SetDynamicColors(true)
    
    	textColor := "black::d"
    	switch message.LogLevel {
    	case node.LOG_LEVEL_INFO:
    		fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]INFO [black::d]]")
    	case node.LOG_LEVEL_SUCCESS:
    		fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][  [green::d]OK  [black::d]]")
    	case node.LOG_LEVEL_WARNING:
    		fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [yellow::d]WARN [black::d]]")
    
    		textColor = "yellow::d"
    	case node.LOG_LEVEL_FAILURE:
    		fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [red::d]FAIL [black::d]]")
    
    		textColor = "red::d"
    	case node.LOG_LEVEL_DEBUG:
    		fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [black::b]NOTE [black::d]]")
    
    		textColor = "black::b"
    	}
    
    	fmt.Fprintf(logEntry.TimeContainer, "  [black::b]"+message.Time.Format("15:04:05"))
    	if message.Source == "Node" {
    		fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.Message)
    	} else {
    		fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.Source+": "+message.Message)
    	}
    
    	logEntry.Primitive.
    		SetColumns(11, 0, 11).
    		SetRows(1).
    		SetBorders(false).
    		AddItem(logEntry.TimeContainer, 0, 0, 1, 1, 0, 0, false).
    		AddItem(logEntry.MessageContainer, 0, 1, 1, 1, 0, 0, false).
    		AddItem(logEntry.LogLevelContainer, 0, 2, 1, 1, 0, 0, false)
    
    	return logEntry
    }