MCPcopy Index your code
hub / github.com/jetify-com/devbox / LogValue

Method LogValue

nix/command.go:103–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101}
102
103func (c *Cmd) LogValue() slog.Value {
104 attrs := []slog.Attr{
105 slog.Any("args", c.Args),
106 }
107 if c.execCmd == nil {
108 return slog.GroupValue(attrs...)
109 }
110 attrs = append(attrs, slog.String("path", c.execCmd.Path))
111
112 var exitErr *exec.ExitError
113 if errors.As(c.err, &exitErr) {
114 stderr := c.stderrExcerpt(exitErr.Stderr)
115 if len(stderr) != 0 {
116 attrs = append(attrs, slog.String("stderr", stderr))
117 }
118 }
119 if proc := c.execCmd.Process; proc != nil {
120 attrs = append(attrs, slog.Int("pid", proc.Pid))
121 }
122 if procState := c.execCmd.ProcessState; procState != nil {
123 if procState.Exited() {
124 attrs = append(attrs, slog.Int("code", procState.ExitCode()))
125 }
126 if status, ok := procState.Sys().(syscall.WaitStatus); ok && status.Signaled() {
127 if status.Signaled() {
128 attrs = append(attrs, slog.String("signal", status.Signal().String()))
129 }
130 }
131 }
132 if c.dur != 0 {
133 attrs = append(attrs, slog.Duration("dur", c.dur))
134 }
135 return slog.GroupValue(attrs...)
136}
137
138// String returns c as a shell-quoted string.
139func (c *Cmd) String() string {

Callers

nothing calls this directly

Calls 2

stderrExcerptMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected