Documentation ¶
Overview ¶
Package execlog handles stdout and stderr pipes of started commands and logs them in JSON using the provided logger
Index ¶
- Constants
- func RunBuffering(cmd *exec.Cmd, cmdName string) (err error)
- func RunStreaming(cmd *exec.Cmd, cmdName string) (err error)
- type LogWriter
- type StreamingCmd
- func RunStreamingNoWait(cmd *exec.Cmd, cmdName string) (streamingCmd *StreamingCmd, err error)
- func RunStreamingNoWaitWithWriter(cmd *exec.Cmd, cmdName string, stdoutWriter io.Writer, stderrWriter io.Writer) (streamingCmd *StreamingCmd, err error)
- func StreamingCmdFromProcess(process *os.Process) *StreamingCmd
Constants ¶
const ( // PipeKey is the key for the pipe the log refers to PipeKey = "pipe" // StdOut is the PipeKey value for stdout StdOut = "stdout" // StdErr is the PipeKey value for stderr StdErr = "stderr" )
Variables ¶
This section is empty.
Functions ¶
func RunBuffering ¶
RunBuffering creates two dedicated pipes for stdout and stderr, run the command and logs its output after the command exited
Types ¶
type LogWriter ¶
LogWriter implements the `Writer` interface using the logger, It uses "Info" as logging level.
type StreamingCmd ¶
type StreamingCmd struct {
// contains filtered or unexported fields
}
StreamingCmd contains the context of a running streaming command
func RunStreamingNoWait ¶
func RunStreamingNoWait(cmd *exec.Cmd, cmdName string) (streamingCmd *StreamingCmd, err error)
RunStreamingNoWait executes the command redirecting its stdout and stderr to the logger. This function does not wait for command to terminate.
func RunStreamingNoWaitWithWriter ¶
func RunStreamingNoWaitWithWriter( cmd *exec.Cmd, cmdName string, stdoutWriter io.Writer, stderrWriter io.Writer, ) (streamingCmd *StreamingCmd, err error)
RunStreamingNoWaitWithWriter executes the command redirecting its stdout and stderr to the corresponding writers. This function does not wait for command to terminate. You can invoke StreamingCmd.Wait() to wait for the command termination and retrieve the exit status.
func StreamingCmdFromProcess ¶
func StreamingCmdFromProcess(process *os.Process) *StreamingCmd
StreamingCmdFromProcess creates a StreamingCmd starting from an existing os.Process. This is useful when we want to adopt a running PostgreSQL instance.
func (*StreamingCmd) Wait ¶
func (se *StreamingCmd) Wait() error
Wait waits for the command to exit and waits for any copying from stdout or stderr to complete.
The returned error is nil if the command runs, has no problems, and exits with a zero exit status.
If the command fails to run or doesn't complete successfully, the error is of type *exec.ExitError. Other error types may be returned for I/O problems.
This implements the same interface of Wait method of exec.Cmd struct