system

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FatalError

func FatalError(name string, error string)

FatalError tries to write a log error and exist with the status code notest

func Log

func Log(level string, message string, params ...interface{})

Log saves a log message with the specified level and parameters to the configured log targets.

func LogInit

func LogInit(config LogConfig)

LogInit initializes the logging system based on the provided configuration. It sets up loggers for writing to stdout/stderr or file, and sets the minimum logging level. If the configuration specifies "testing_buffer" as the file, it redirects logging output to a testing buffer. The loggers are stored in the loggers map for later use.

Types

type Command

type Command struct {
	Command     string            // The command to be executed.
	Environment map[string]string // Environment variables for the command.
	Directory   string            // Working directory for the command.
	Timeout     int               // Timeout duration in seconds.
	Shell       string            // Shell used to execute the command.
	Stdout      string            // Standard output of the command.
	Stderr      string            // Standard error of the command.
	Rc          int               // Return code of the command.
	Error       error             // Error encountered during command execution.
}

Command represents a system command to be executed.

func NewCommand

func NewCommand(command string) Command

NewCommand creates a new Command with default settings.

func (*Command) Execute

func (c *Command) Execute() error

Execute executes the command and captures its output.

type LogBuilder

type LogBuilder struct {
	// contains filtered or unexported fields
}

func NewLogBuilder

func NewLogBuilder(message string) *LogBuilder

NewLogBuilder creates a new LogBuilder instance with the specified log message.

func (*LogBuilder) Level

func (b *LogBuilder) Level(level string) *LogBuilder

Level sets the logging level for the LogBuilder.

func (*LogBuilder) Save

func (b *LogBuilder) Save()

Save builds the log parameters and invokes the Log function to save the log message.

func (*LogBuilder) Set

func (b *LogBuilder) Set(params ...interface{}) *LogBuilder

Set adds parameters to the LogBuilder.

type LogConfig

type LogConfig struct {
	File  string `file,validate:"filepath"`
	Level string `minimal_level,validate:"oneof=debug info warn error"`
	Quiet bool
	Json  bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL