io

package
v0.0.0-...-fa857ea Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OktetoK8sLoggerEnabledEnvVar = "OKTETO_K8S_REQUESTS_LOGGER_ENABLED"
	K8sLogsFileName              = "okteto-k8s.log"
)
View Source
const (
	// JSONFormat represents a json logger
	JSONFormat string = "json"

	// 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"
)
View Source
const (
	// OktetoDisableSpinnerEnvVar if true spinner is disabled
	OktetoDisableSpinnerEnvVar = "OKTETO_DISABLE_SPINNER"
)

Variables

View Source
var (

	// DefaultLogLevel is the default log level
	DefaultLogLevel = slog.LevelWarn
)

Functions

func GetK8sLoggerFilePath

func GetK8sLoggerFilePath(okHome string) string

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) Debug

func (ol Controller) Debug(msg string)

Debug logs a debug message

func (Controller) Debugf

func (ol Controller) Debugf(format string, args ...any)

Debugf logs a debug message

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) Info

func (ol Controller) Info(msg string)

Info logs an info message

func (Controller) Infof

func (ol Controller) Infof(format string, args ...any)

Infof logs an info message

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
}

func NewK8sLogger

func NewK8sLogger() *K8sLogger

NewK8sLogger creates a new k8s logger

func (K8sLogger) Debug

func (ol K8sLogger) Debug(msg string)

Debug logs a debug message

func (K8sLogger) Debugf

func (ol K8sLogger) Debugf(format string, args ...any)

Debugf logs a debug message

func (K8sLogger) Info

func (ol K8sLogger) Info(msg string)

Info logs an info message

func (K8sLogger) Infof

func (ol K8sLogger) Infof(format string, args ...any)

Infof logs an info message

func (*K8sLogger) IsEnabled

func (k *K8sLogger) IsEnabled() bool

IsEnabled returns true if the k8s logger is enabled

func (*K8sLogger) Log

func (k *K8sLogger) Log(respStatusCode int, reqMethod, reqUrl string)

Log logs the http request and response status code

func (K8sLogger) SetLevel

func (ol K8sLogger) SetLevel(lvl string)

SetLevel sets the level of the logger

func (*K8sLogger) Start

func (k *K8sLogger) Start(okHome, cmdName, flags string)

Start configures the k8s logger to write to file

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

func (*OutputController) Write

func (oc *OutputController) Write(p []byte) (n int, err error)

Write logs into the buffer but does not print anything

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

Jump to

Keyboard shortcuts

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