formatProcInfo renders one process snapshot as a single line.
(info proc.Info)
| 104 | |
| 105 | // formatProcInfo renders one process snapshot as a single line. |
| 106 | func formatProcInfo(info proc.Info) string { |
| 107 | cmd := info.Command |
| 108 | if len(cmd) > 80 { |
| 109 | cmd = cmd[:77] + "..." |
| 110 | } |
| 111 | if info.State == proc.StateRunning { |
| 112 | return fmt.Sprintf("%s running (pid %d, up %s): %s", |
| 113 | info.ID, info.PID, time.Since(info.Started).Round(time.Second), cmd) |
| 114 | } |
| 115 | return fmt.Sprintf("%s exited (code %d, ran %s): %s", |
| 116 | info.ID, info.ExitCode, info.Ended.Sub(info.Started).Round(time.Second), cmd) |
| 117 | } |
| 118 | |
| 119 | // compile-time assertion that the adapter satisfies the plugin interface. |
| 120 | var _ plugins.ProcAdapter = (*procToolAdapter)(nil) |