Documentation
¶
Index ¶
- Constants
- func CheckDirectory(path string) error
- func CheckDirectoryOrCreate(ctx context.Context, path string) error
- func CheckEmptyDirectoryOrCreate(ctx context.Context, path string) error
- func ChildContext(ctx context.Context, name string) context.Context
- func CopyDirectory(ctx context.Context, src, dst string) error
- func CopyFile(_ context.Context, from string, to string) error
- func CopyFileWithReplacement(from string, to string, replacements []Replacement) error
- func CreateDirIf(path string) error
- func DefaultTo(s string, defaultValue string) string
- func DirectoryExists(p string) bool
- func Exit(msg string, args ...any)
- func ExitIf(b bool, msg string, args ...any)
- func ExitIfNot(b bool, msg string, args ...any)
- func ExitOnError(err error, msg string, args ...any)
- func FileExists(p string) bool
- func ForwardLogs(r io.ReadCloser, w io.Writer)
- func GenerateTree(p, indent string) (string, error)
- func GlobalOverride() bool
- func HandleError(err error)
- func IsDebug() bool
- func IsOutputError(err error) (bool, error)
- func IsTrace() bool
- func IsUserError(err error) bool
- func IsUserWarning(err error) bool
- func MultiErrors(errs ...error) error
- func Must[T any](t T, err error) T
- func NewContext() context.Context
- func NewInvalidArgumentError(s string) error
- func NewOutputError(format string, args ...any) error
- func NewUserWarning(format string, args ...any) error
- func ParseError(s string) error
- func Pointer[T any](t T) *T
- func PointerEqual[T comparable](t *T, target T) bool
- func ProtoType(m proto.Message) string
- func RequireExec(bins ...string) ([]string, bool)
- func SetLogLevel(lvl LogLevel)
- func SetOverride(o bool)
- func SetTodo(t bool)
- func ToCamelCase(s string) string
- func ToDNSCase(s string) string
- func ToKebabCase(str string) string
- func ToLowerCase(s string) string
- func ToSnakeCase(s string) string
- func ToTitle(s string) string
- func Todo() bool
- func TypeOf[T any]() string
- func UnexpectedExitOnError(err error, msg string, args ...any)
- func UserErrorMessage(err error) string
- func UserWarnMessage(err error) string
- func WithIgnore(ctx context.Context, ignore Ignore) context.Context
- func WithOverride(ctx context.Context, override Override) context.Context
- func WrapStart(cmd *exec.Cmd, logger BaseLogger) error
- func Wrapf(err error, format string, args ...any) error
- type BaseLogger
- type Case
- type ContextIgnoreKey
- type ContextLoggerKey
- type ContextOverrideKey
- type CopyInstruction
- type Dir
- type DirReader
- type FSReader
- func (fr *FSReader) Absolute(dir Dir) string
- func (fr *FSReader) AbsoluteDir(dir Dir) string
- func (fr *FSReader) AbsoluteFile(f File) string
- func (fr *FSReader) At(root string) *FSReader
- func (fr *FSReader) Copy(s string, file string) error
- func (fr *FSReader) ReadDir(dir Dir) ([]os.DirEntry, error)
- func (fr *FSReader) ReadFile(f File) ([]byte, error)
- type File
- type FileSystem
- type Ignore
- type IgnoreNoneHandler
- type IgnorePatterns
- type InvalidArgumentError
- type LogLevel
- type LogMode
- type Logger
- func (l *Logger) Action() string
- func (l *Logger) Actions() []string
- func (l *Logger) Catch()
- func (l *Logger) DebugMe(format string, args ...any)
- func (l *Logger) Debugf(format string, args ...any)
- func (l *Logger) Errorf(format string, args ...any) error
- func (l *Logger) Info(format string, args ...any)
- func (l *Logger) Message(format string, args ...any)
- func (l *Logger) Oops(format string, args ...any)
- func (l *Logger) SetLevel(lvl LogLevel) BaseLogger
- func (l *Logger) SetLogMethod(mode LogMode) BaseLogger
- func (l *Logger) SetLogMode(mode LogMode)
- func (l *Logger) TODO(format string, args ...any)
- func (l *Logger) Tracef(format string, args ...any)
- func (l *Logger) UserFatal(err error)
- func (l *Logger) UserFatalMessage(err error) string
- func (l *Logger) Warn(format string, args ...any)
- func (l *Logger) WarnOnError(err error)
- func (l *Logger) WarnUnique(err error)
- func (l *Logger) With(format string, args ...any) BaseLogger
- func (l *Logger) Wrap(err error) error
- func (l *Logger) Wrapf(err error, format string, args ...any) error
- func (l *Logger) Write(p []byte) (n int, err error)
- type NilError
- type OutputError
- type Override
- type Replacement
- type S
- type SilentOverrideHandler
- type SkipOverrideHandler
- type UserError
- type UserWarning
Constants ¶
View Source
const ( Base = ContextLoggerKey("base") Agent = ContextLoggerKey("agent") Service = ContextLoggerKey("service") )
View Source
const ( LastAction = LogMode("last_action") StartAndLastAction = LogMode("start_and_last_action") AllActions = LogMode("all_actions") )
Variables ¶
This section is empty.
Functions ¶
func CheckDirectory ¶
CheckDirectory checks if a directory exists otherwise returns an error
func ChildContext ¶ added in v0.0.51
ChildContext
func CopyDirectory ¶
CopyDirectory recursively copies a directory
func CopyFileWithReplacement ¶
func CopyFileWithReplacement(from string, to string, replacements []Replacement) error
func CreateDirIf ¶
func DirectoryExists ¶ added in v0.0.13
func ExitOnError ¶
func FileExists ¶
func ForwardLogs ¶
func ForwardLogs(r io.ReadCloser, w io.Writer)
func GenerateTree ¶
GenerateTree recursively generates a string representation of the directory tree
func GlobalOverride ¶ added in v0.0.51
func GlobalOverride() bool
func HandleError ¶
func HandleError(err error)
func IsOutputError ¶
func IsUserError ¶
func IsUserWarning ¶
func MultiErrors ¶ added in v0.0.13
func NewContext ¶ added in v0.0.51
NewContext provides a context with a logger
func NewInvalidArgumentError ¶ added in v0.0.51
func NewOutputError ¶
func NewUserWarning ¶
func ParseError ¶
func PointerEqual ¶ added in v0.0.51
func PointerEqual[T comparable](t *T, target T) bool
PointerEqual returns true if pointer is not nil and value is equal
func RequireExec ¶ added in v0.0.15
func SetLogLevel ¶ added in v0.0.51
func SetLogLevel(lvl LogLevel)
func SetOverride ¶ added in v0.0.13
func SetOverride(o bool)
func ToCamelCase ¶ added in v0.0.51
ToCamelCase converts a string to camelCase
func ToKebabCase ¶ added in v0.0.51
ToKebabCase converts a string to kebab-case
func ToLowerCase ¶ added in v0.0.51
func ToSnakeCase ¶ added in v0.0.51
ToSnakeCase converts a string to snake_case
func UnexpectedExitOnError ¶
func UserErrorMessage ¶
func UserWarnMessage ¶
func WithIgnore ¶ added in v0.0.51
func WithOverride ¶ added in v0.0.51
Types ¶
type BaseLogger ¶
type BaseLogger interface { SetLevel(lvl LogLevel) BaseLogger SetLogMethod(actions LogMode) BaseLogger With(format string, args ...any) BaseLogger Info(format string, args ...any) Tracef(format string, args ...any) Debugf(format string, args ...any) DebugMe(format string, args ...any) Warn(format string, args ...any) TODO(format string, args ...any) // Wrap uses action to wrap the error Wrap(err error) error // Wrapf uses action to wrap the error and other message Wrapf(err error, format string, args ...any) error Errorf(format string, args ...any) error Oops(format string, args ...any) // Write does the actual work Write(p []byte) (n int, err error) WarnOnError(err error) }
BaseLogger is the Minimum logger interface
func GetAgentLogger ¶ added in v0.0.51
func GetAgentLogger(ctx context.Context) BaseLogger
func GetLogger ¶ added in v0.0.51
func GetLogger(ctx context.Context) BaseLogger
GetLogger returns the logger from the context - Base - Agent
func GetServiceLogger ¶ added in v0.0.51
func GetServiceLogger(ctx context.Context) BaseLogger
type Case ¶ added in v0.0.51
type ContextIgnoreKey ¶ added in v0.0.51
type ContextIgnoreKey string
const (
IgnoreKey ContextIgnoreKey = "ignore"
)
type ContextLoggerKey ¶ added in v0.0.13
type ContextLoggerKey string
type ContextOverrideKey ¶ added in v0.0.51
type ContextOverrideKey string
const (
OverrideKey ContextOverrideKey = "override"
)
type CopyInstruction ¶
type DirReader ¶ added in v0.0.13
type DirReader struct {
// contains filtered or unexported fields
}
func NewDirReader ¶ added in v0.0.13
func NewDirReader() *DirReader
func (*DirReader) AbsoluteDir ¶ added in v0.0.13
func (*DirReader) AbsoluteFile ¶ added in v0.0.13
type FSReader ¶ added in v0.0.13
func (*FSReader) AbsoluteDir ¶ added in v0.0.13
func (*FSReader) AbsoluteFile ¶ added in v0.0.13
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) RelativePath ¶
type FileSystem ¶ added in v0.0.13
type Ignore ¶ added in v0.0.51
func IgnoreNone ¶ added in v0.0.51
func IgnoreNone() Ignore
type IgnoreNoneHandler ¶ added in v0.0.51
type IgnoreNoneHandler struct{}
func (IgnoreNoneHandler) Skip ¶ added in v0.0.51
func (i IgnoreNoneHandler) Skip(string) bool
type IgnorePatterns ¶ added in v0.0.51
type IgnorePatterns struct {
// contains filtered or unexported fields
}
func NewIgnore ¶ added in v0.0.51
func NewIgnore(patterns ...string) IgnorePatterns
func (IgnorePatterns) Skip ¶ added in v0.0.51
func (ign IgnorePatterns) Skip(file string) bool
type InvalidArgumentError ¶ added in v0.0.51
type InvalidArgumentError struct {
// contains filtered or unexported fields
}
func (*InvalidArgumentError) Error ¶ added in v0.0.51
func (i *InvalidArgumentError) Error() string
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) SetLevel ¶
func (l *Logger) SetLevel(lvl LogLevel) BaseLogger
func (*Logger) SetLogMethod ¶ added in v0.0.51
func (l *Logger) SetLogMethod(mode LogMode) BaseLogger
func (*Logger) SetLogMode ¶ added in v0.0.51
func (*Logger) UserFatalMessage ¶
func (*Logger) WarnOnError ¶ added in v0.0.51
func (*Logger) WarnUnique ¶ added in v0.0.9
type NilError ¶ added in v0.0.51
type NilError[T any] struct { }
func NewNilError ¶ added in v0.0.51
type OutputError ¶
type OutputError struct {
// contains filtered or unexported fields
}
func (*OutputError) Error ¶
func (u *OutputError) Error() string
type Override ¶ added in v0.0.13
func GetOverride ¶ added in v0.0.51
func SilentOverride ¶ added in v0.0.51
func SilentOverride() Override
type Replacement ¶
type SilentOverrideHandler ¶ added in v0.0.51
type SilentOverrideHandler struct{}
func (SilentOverrideHandler) Replace ¶ added in v0.0.51
func (s SilentOverrideHandler) Replace(string) bool
type SkipOverrideHandler ¶ added in v0.0.51
type SkipOverrideHandler struct{}
func (SkipOverrideHandler) Replace ¶ added in v0.0.51
func (s SkipOverrideHandler) Replace(string) bool
type UserWarning ¶
type UserWarning struct {
// contains filtered or unexported fields
}
func (*UserWarning) Error ¶
func (u *UserWarning) Error() string
Click to show internal directories.
Click to hide internal directories.