Documentation ¶
Overview ¶
Package emitter emits the translated trice strings.
Example (NewColorDisplay) ¶
p := newColorDisplay(os.Stdout, "none") l1 := []string{"msg:This is ", "the 1st ", "line"} l2 := []string{"MSG:This is ", "the 2nd ", "line"} p.WriteLine(l1) p.WriteLine(l2)
Output: This is the 1st line MSG:This is the 2nd line
Example (NewLocalDisplay) ¶
p := newLocalDisplay(os.Stdout) l1 := []string{"This is ", "the 1st ", "line"} l2 := []string{"This is ", "the 2nd ", "line"} p.WriteLine(l1) p.WriteLine(l2)
Output: This is the 1st line This is the 2nd line
Index ¶
- Constants
- Variables
- func BanOrPickFilter(b []byte) (n int)
- func Colorize(s string) (r string)
- func FindTagName(name string) (tagName string, err error)
- func PrintTagStatistics(w io.Writer)
- func ScDisplayServer(w io.Writer) error
- func ScShutdownRemoteDisplayServer(w io.Writer, timeStamp int64, args ...string) error
- func ShowAllColors()
- func TagEvents(ch string) int
- type DisplayServer
- type LineWriter
- type TriceLineComposer
Examples ¶
Constants ¶
const SyncPacketPattern = "inf:[TRICE_SYNC_PACKET 0x89abcdef]"
SyncPacketPattern is used if a sync packet arrives
Variables ¶
var ( // Verbose gives more information on output if set. The value is injected from main packages. Verbose bool // HostStamp is used for line timestamps. // off = no timestamp // none = no timestamp // LOCmicro = local time with microseconds // UTCmicro = universal time with microseconds // zero = fixed "2006-01-02_1504-05" timestamp (for tests) HostStamp string // Prefix starts lines. It follows line timestamp, if any. Prefix string // Suffix lollows lines. Usually empty. Suffix string // ColorPalette determines the way color is handled. // off = no color handling at all. Lower case color prefixes are not removed. Use with care. // none = no colors. Lower case color prefixes are removed. // default = color codes added (TODO: change to ANSI) ColorPalette string // IPAddr ist the remote display IP address. IPAddr string // IPPort ist the remote display port number. IPPort string // DisplayRemote if set, sends trice lines over TCP. DisplayRemote bool // TestTableMode is set externally to avoid Prefix overwrite TestTableMode bool // NextLine is set true as help for decoder.TestTableMode, where it is clreared at line start. NextLine bool // Ban is a string slice containing all channel descriptors to suppress Ban channelArrayFlag // Pick is a string slice containing all channel descriptors only to display Pick channelArrayFlag )
var ( // LogLevel is usable to suppress less important logs. LogLevel = "all" AllStatistics bool // Keep the complete statistics when Trice is closed. TagStatistics bool // Print the occured count for each Trice log when Trice is closed. )
var Tags = []tag{ {0, []string{"Fatal", "fatal", "FATAL"}, colorizeFATAL}, {0, []string{"crit", "Critical", "critical", "CRITICAL", "Crit", "CRIT"}, colorizeCRITICAL}, {0, []string{"em", "Emergency", "emergency", "EMERGENCY"}, colorizeEMERGENCY}, {0, []string{"e", "Error", "err", "error", "E", "ERR", "ERROR"}, colorizeERROR}, {0, []string{"w", "wrn", "Warning", "warning", "W", "WRN", "WARNING", "Warn", "warn", "WARN"}, colorizeWARNING}, {0, []string{"att", "attention", "Attention", "ATT", "ATTENTION"}, colorizeATTENTION}, {0, []string{"i", "inf", "info", "Info", "informal", "I", "INF", "INFO", "INFORMAL"}, colorizeINFO}, {0, []string{"d", "db", "Debug", "dbg", "deb", "debug", "D", "DB", "DBG", "DEBUG"}, colorizeDEBUG}, {0, []string{"tr", "Trace", "trace", "TRACE"}, colorizeTRACE}, {0, []string{"tim", "time", "TIM", "TIME", "TIMESTAMP", "timestamp", "Timestamp"}, colorizeTIME}, {0, []string{"m", "msg", "message", "M", "MSG", "MESSAGE", "OK"}, colorizeMESSAGE}, {0, []string{"r", "rx", "rd", "read", "rd_", "RD", "RD_", "READ"}, colorizeREAD}, {0, []string{"w", "tx", "wr", "write", "wr_", "WR", "WR_", "WRITE"}, colorizeWRITE}, {0, []string{"rx", "receive", "RECEIVE", "Receive", "RX"}, colorizeRECEIVE}, {0, []string{"tx", "transmit", "TRANSMIT", "Transmit", "TX"}, colorizeTRANSMIT}, {0, []string{"dia", "diag", "Diag", "DIA", "DIAG"}, colorizeDIAG}, {0, []string{"int", "isr", "ISR", "INT", "interrupt", "Interrupt", "INTERRUPT"}, colorizeINTERRUPT}, {0, []string{"s", "sig", "signal", "S", "SIG", "SIGNAL"}, colorizeSIGNAL}, {0, []string{"t", "tst", "test", "T", "TST", "TEST"}, colorizeTEST}, {0, []string{"def", "Default", "DEFAULT", "default"}, colorizeDEFAULT}, {0, []string{"note", "Notice", "NOTICE", "notice", "Note", "NOTE"}, colorizeNOTICE}, {0, []string{"Alert", "alert", "ALERT"}, colorizeALERT}, {0, []string{"Assert", "assert", "ASSERT"}, colorizeASSERT}, {0, []string{"a", "Alarm", "alarm", "ALARM"}, colorizeALARM}, {0, []string{"CYCLE_ERROR"}, colorizeCYCLE}, {0, []string{"v", "Verbose", "verbose", "VERBOSE"}, colorizeVERBOSE}, }
Tags contains all usable trice Tags and their possible names.
Functions ¶
func BanOrPickFilter ¶ added in v0.31.0
BanOrPickFilter returns len of b if b ist not filtered out, otherwise 0. If Ban and Pick are nil nothing is filtered out. If Ban and Pick are both not nil this is a fatal error (os.Exit). If b starts with a known channel specifier existent in Ban 0, is returned. If b starts with a known channel specifier existent in Pick len of b, is returned.
func Colorize ¶ added in v0.72.4
colorize prefixes s with an ansi color code according to these conditions: If p.colorPalette is "off", do nothing. If p.colorPalette is "none" remove only lower case channel info "col:" If "COL:" is start of string add ANSI color code according to COL: If "col:" is start of string replace "col:" with ANSI color code according to col: Additionally, if global variable LogLevel is not the default "all", but found inside ColorChannels, logs with higher index positions are suppressed. As special case LogLevel == "off" does not output anything.
func FindTagName ¶ added in v0.71.0
func PrintTagStatistics ¶ added in v0.72.4
PrintTagStatistics shows the amount of occurred tag events.
func ScDisplayServer ¶
ScDisplayServer is the endless function called when trice tool acts as remote display. All in Server struct registered RPC functions are reachable, when displayServer runs.
func ScShutdownRemoteDisplayServer ¶
ScShutdownRemoteDisplayServer connects to a client to send shutdown message to display server. 0==timeStamp -> no timestamp in shutdown message, use for tests. 1==timeStamp -> timestamp in shutdown message, use normally. It accepts 0 to 2 string arguments as args. More arguments are ignored. For not given parameters default values are taken. The parameters are in the following order. args[0] (ipa) is the IP address to be used to connect to the remote display. args[1] (ipp) is the IP port to be used to connect to the remote display.
func ShowAllColors ¶ added in v0.52.0
func ShowAllColors()
Types ¶
type DisplayServer ¶ added in v0.51.1
type DisplayServer struct {
Display colorDisplay // todo: lineWriter?
}
DisplayServer is the RPC struct for registered DisplayServer functions. Its methods must be exported.
func (*DisplayServer) ColorPalette ¶ added in v0.51.1
func (p *DisplayServer) ColorPalette(s []string, reply *int64) error
ColorPalette is the exported server function for color palette, if trice tool acts as display server. By declaring it as a Server struct method it is registered as RPC destination.
func (*DisplayServer) LogSetFlags ¶ added in v0.51.1
func (p *DisplayServer) LogSetFlags(f []int64, r *int64) error
LogSetFlags is called remotely to ...
type LineWriter ¶
type LineWriter interface {
WriteLine([]string)
}
LineWriter is the common interface for output devices. The string slice `line` contains all string parts of one line including prefix and suffix. The last string part is without newline char and must be handled by the output device.
type TriceLineComposer ¶
type TriceLineComposer struct { Line []string // line collector // contains filtered or unexported fields }
TriceLineComposer collects all partial strings forming one line.
func New ¶
func New(w io.Writer) *TriceLineComposer
New creates the emitter instance and returns a string writer to be used for emitting.
func (*TriceLineComposer) Write ¶ added in v0.18.4
func (p *TriceLineComposer) Write(b []byte) (n int, err error)
Write treats received buffer as a string.
func (*TriceLineComposer) WriteString ¶
func (p *TriceLineComposer) WriteString(s string) (n int, err error)
WriteString implements the io.StringWriter interface. The triceLineComposer can use it. WriteString uses the internal line writer p.lw for writing out full lines. If s is empty, WriteString returns 0, nil. If p.line is empty, the actual timestamp and the prefix are added to p.line. If s is without newline it is added to p.line and WriteString returns. If s ends with newline it is added to p.line and also the suffix is added to p.line and pline is written to p.lw. If s contains several newlines it is split there and the substrings are handled accordingly. That means it writes internally a separate line for each substring (in s) ending with a newline.