Skip to content

Commit

Permalink
Add an extra token to each line of stderr from termshark processes
Browse files Browse the repository at this point in the history
For example:

time="2022-07-02T12:46:22-04:00" level=error msg="tshark: Configuration Profile \"test1\" does not exist" cmd=/home/gcla/bin/tshark

This might make it a little easier to understand when a tshark process
fails to run correctly.

I may go further and capture stderr for display in a UI error dialog.
  • Loading branch information
gcla committed Jul 2, 2022
1 parent db5daa0 commit 7601e01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pcap/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (c *Command) String() string {
func (c *Command) Start() error {
c.Lock()
defer c.Unlock()
c.Cmd.Stderr = log.StandardLogger().Writer()
c.Cmd.Stderr = termshark.ErrLogger("cmd", c.Path)
c.PutInNewGroupOnUnix()
res := c.Cmd.Start()
return res
Expand Down
7 changes: 7 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,13 @@ func SaveOffsetToConfig(name string, offsets2 []resizable.Offset) {

//======================================================================

func ErrLogger(key string, val string) *io.PipeWriter {
l := log.StandardLogger()
return log.NewEntry(l).WithField(key, val).WriterLevel(log.ErrorLevel)
}

//======================================================================

// Need to publish fields for template use
type JumpPos struct {
Summary string `json:"summary"`
Expand Down

0 comments on commit 7601e01

Please sign in to comment.