Documentation
¶
Index ¶
- Constants
- Variables
- func GetK8sLoggerFilePath(okHome string) string
- type Controller
- func (ol Controller) Debug(msg string)
- func (ol Controller) Debugf(format string, args ...any)
- func (ioc *Controller) In() *InputController
- func (ol Controller) Info(msg string)
- func (ol Controller) Infof(format string, args ...any)
- func (ioc *Controller) Logger() *oktetoLogger
- func (ioc *Controller) Out() *OutputController
- func (ol Controller) SetLevel(lvl string)
- func (ioc *Controller) SetOutputFormat(output string)
- func (ioc *Controller) SetStage(stage string)
- type InputController
- type InvalidLogLevelError
- type K8sLogger
- func (ol K8sLogger) Debug(msg string)
- func (ol K8sLogger) Debugf(format string, args ...any)
- func (ol K8sLogger) Info(msg string)
- func (ol K8sLogger) Infof(format string, args ...any)
- func (k *K8sLogger) IsEnabled() bool
- func (k *K8sLogger) Log(respStatusCode int, reqMethod, reqUrl string)
- func (ol K8sLogger) SetLevel(lvl string)
- func (k *K8sLogger) Start(okHome, cmdName, flags string)
- type OktetoSpinner
- type OutputController
- func (oc *OutputController) Infof(format string, args ...any)
- func (oc *OutputController) Print(args ...any)
- func (oc *OutputController) Printf(format string, args ...any)
- func (oc *OutputController) Println(args ...any)
- func (oc *OutputController) SetOutputFormat(output string)
- func (oc *OutputController) SetStage(stage string)
- func (oc *OutputController) Spinner(msg string) OktetoSpinner
- func (oc *OutputController) Success(format string, args ...any)
- func (oc *OutputController) Warning(format string, args ...any)
- func (oc *OutputController) Write(p []byte) (n int, err error)
- type PlainDecorator
- type TTYDecorator
Constants ¶
const ( OktetoK8sLoggerEnabledEnvVar = "OKTETO_K8S_REQUESTS_LOGGER_ENABLED" K8sLogsFileName = "okteto-k8s.log" )
const ( // JSONFormat represents a json logger JSONFormat string = "json" // SilentFormat represents a silent logger SilentFormat string = "silent" // DebugLevel is the debug level DebugLevel = "debug" // InfoLevel is the info level InfoLevel = "info" // WarnLevel is the warn level WarnLevel = "warn" // ErrorLevel is the error level ErrorLevel = "error" )
const (
// OktetoDisableSpinnerEnvVar if true spinner is disabled
OktetoDisableSpinnerEnvVar = "OKTETO_DISABLE_SPINNER"
)
Variables ¶
var ( // DefaultLogLevel is the default log level DefaultLogLevel = slog.LevelWarn )
Functions ¶
func GetK8sLoggerFilePath ¶
GetK8sLoggerFilePath returns the path of the okteto k8s logs file
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages the input and output for the CLI
func NewIOController ¶
func NewIOController() *Controller
NewIOController returns a new input/output controller
func (*Controller) In ¶
func (ioc *Controller) In() *InputController
In is utilized to collect user input for operations that require user interaction or data entry. When 'in' is used, the program will pause and wait for the user to provide input. This input is essential for executing specific actions, and the program proceeds once the user provides the necessary data or response.
func (*Controller) Logger ¶
func (ioc *Controller) Logger() *oktetoLogger
Logger is used for recording and categorizing log messages at different levels (e.g., info, debug, warning). These log messages can be filtered based on the log level set by the user. Messages with log levels lower than the user-defined log level will not be displayed to the user.
func (*Controller) Out ¶
func (ioc *Controller) Out() *OutputController
Out is used for displaying information to the user regardless of the log level set. It will always be shown to the user, regardless of whether the log level is 'info', 'debug', 'warning', or any other level.
func (Controller) SetLevel ¶
func (ol Controller) SetLevel(lvl string)
SetLevel sets the level of the logger
func (*Controller) SetOutputFormat ¶
func (ioc *Controller) SetOutputFormat(output string)
SetOutputFormat sets the output format for the CLI. We need that the logger and the output generates the same type of messages, so we don't end up mixing formats like json and tty.
func (*Controller) SetStage ¶
func (ioc *Controller) SetStage(stage string)
SetStage sets the current stage where the CLI is performing.
type InputController ¶
type InputController struct {
// contains filtered or unexported fields
}
type InvalidLogLevelError ¶
type InvalidLogLevelError struct {
// contains filtered or unexported fields
}
InvalidLogLevelError is returned when the log level is invalid
func (*InvalidLogLevelError) Error ¶
func (e *InvalidLogLevelError) Error() string
Error returns the error message
type K8sLogger ¶
type K8sLogger struct {
*Controller
}
type OktetoSpinner ¶
type OktetoSpinner interface { Start() Stop() // contains filtered or unexported methods }
OktetoSpinner is the interface for the spinner
type OutputController ¶
type OutputController struct {
// contains filtered or unexported fields
}
OutputController manages the output for the CLI
func (*OutputController) Infof ¶
func (oc *OutputController) Infof(format string, args ...any)
Infof prints a information message to the user
func (*OutputController) Print ¶
func (oc *OutputController) Print(args ...any)
Print prints a line into stdout without a new line at the end
func (*OutputController) Printf ¶
func (oc *OutputController) Printf(format string, args ...any)
Printf prints a line into stdout with a format
func (*OutputController) Println ¶
func (oc *OutputController) Println(args ...any)
Println prints a line into stdout
func (*OutputController) SetOutputFormat ¶
func (oc *OutputController) SetOutputFormat(output string)
SetOutputFormat sets the output format
func (*OutputController) SetStage ¶
func (oc *OutputController) SetStage(stage string)
SetStage sets the stage of the logger if it's json
func (*OutputController) Spinner ¶
func (oc *OutputController) Spinner(msg string) OktetoSpinner
Spinner returns a spinner
func (*OutputController) Success ¶
func (oc *OutputController) Success(format string, args ...any)
Success prints a success message to the user
func (*OutputController) Warning ¶
func (oc *OutputController) Warning(format string, args ...any)
Warning prints a warning message to the user
type PlainDecorator ¶
type PlainDecorator struct{}
PlainDecorator is the decorator for the plain output
func (*PlainDecorator) Information ¶
func (d *PlainDecorator) Information(msg string) string
Information decorates an information message
func (*PlainDecorator) Question ¶
func (d *PlainDecorator) Question(msg string) string
Question decorates a question message
func (*PlainDecorator) Success ¶
func (d *PlainDecorator) Success(msg string) string
Success decorates a success message
func (*PlainDecorator) Warning ¶
func (d *PlainDecorator) Warning(msg string) string
Warning decorates a warning message
type TTYDecorator ¶
type TTYDecorator struct{}
TTYDecorator is the decorator for the TTY
func (*TTYDecorator) Information ¶
func (d *TTYDecorator) Information(msg string) string
Information decorates an information message
func (*TTYDecorator) Question ¶
func (d *TTYDecorator) Question(msg string) string
Question decorates a question message
func (*TTYDecorator) Success ¶
func (d *TTYDecorator) Success(msg string) string
Success decorates a success message
func (*TTYDecorator) Warning ¶
func (d *TTYDecorator) Warning(msg string) string
Warning decorates a warning message