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 ColorChannelEvents(ch string) int
- func PrintColorChannelEvents(w io.Writer)
- func ScDisplayServer(w io.Writer) error
- func ScShutdownRemoteDisplayServer(w io.Writer, timeStamp int64, args ...string) error
- func ShowAllColors()
- 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 tor 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"
)
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 ColorChannelEvents ¶ added in v0.34.0
ColorChannelEvents returns count of occurred channel events. If ch is unknown, the returned value is -1.
func PrintColorChannelEvents ¶ added in v0.34.0
PrintColorChannelEvents shows the amount of occurred channel 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.