log

package
v0.0.0-...-cce75fc Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// TTYFormat represents a tty logger
	TTYFormat string = "tty"
	// PlainFormat represents a plain logger
	PlainFormat string = "plain"
	// JSONFormat represents a json logger
	JSONFormat string = "json"
	// SilentFormat represents a silent logger
	SilentFormat string = "silent"
)
View Source
const (
	// OktetoDisableSpinnerEnvVar if true spinner is disabled
	OktetoDisableSpinnerEnvVar = "OKTETO_DISABLE_SPINNER"
)

Variables

View Source
var (

	// InfoLevel is the json level for information
	InfoLevel = "info"
	// WarningLevel is the json level for warning
	WarningLevel = "warn"
	// ErrorLevel is the json level for error
	ErrorLevel = "error"
	// DebugLevel is the json level for debug
	DebugLevel = "debug"
)

Functions

func AddMaskedWord

func AddMaskedWord(word string)

AddMaskedWord adds a new word to be redacted, only if longer than 5 chars

func AddToBuffer

func AddToBuffer(level, format string, args ...interface{})

AddToBuffer logs into the buffer but does not print anything

func BlueBackgroundString

func BlueBackgroundString(format string, args ...interface{}) string

BlueBackgroundString returns a string in a blue background

func BlueString

func BlueString(format string, args ...interface{}) string

BlueString returns a string in blue

func ConfigureFileLogger

func ConfigureFileLogger(dir, version string)

ConfigureFileLogger configures the file to write

func Debug

func Debug(args ...interface{})

Debug writes a debug-level log

func Debugf

func Debugf(format string, args ...interface{})

Debugf writes a debug-level log with a format

func DisableMasking

func DisableMasking()

DisableMasking will stop showing secrets and vars

func EnableMasking

func EnableMasking()

EnableMasking starts redacting all variables

func Error

func Error(args ...interface{})

Error writes a error-level log

func Errorf

func Errorf(format string, args ...interface{})

Errorf writes a error-level log with a format

func FPrintln

func FPrintln(w io.Writer, args ...interface{})

FPrintln writes a line with colors to specific writer

func FWarning

func FWarning(w io.Writer, format string, args ...interface{})

FWarning prints a message with the warning symbol first, and the text in yellow to a specific writer

func Fail

func Fail(format string, args ...interface{})

Fail prints a message with the error symbol first, and the text in red

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf writes a error-level log with a format

func GetLevel

func GetLevel() string

GetLevel gets the level of the main logger

func GetOutput

func GetOutput() io.Writer

GetOutput returns the log output

func GetOutputBuffer

func GetOutputBuffer() *bytes.Buffer

GetOutputBuffer returns the buffer of the running command

func GetOutputFormat

func GetOutputFormat() string

GetOutputFormat returns the output format of the command

func Green

func Green(format string, args ...interface{})

Green writes a line in green

func Hint

func Hint(format string, args ...interface{})

Hint prints a message with the text in blue

func Info

func Info(args ...interface{})

Info writes a info-level log

func Infof

func Infof(format string, args ...interface{})

Infof writes a info-level log with a format

func Information

func Information(format string, args ...interface{})

Information prints a message with the information symbol first, and the text in blue

func Init

func Init(level logrus.Level)

Init configures the logger for the package to use.

func IsDebug

func IsDebug() bool

IsDebug checks if the level of the main logger is DEBUG or TRACE

func IsInteractive

func IsInteractive() bool

IsInteractive checks if the writer is interactive

func Print

func Print(args ...interface{})

Print writes a line with colors

func Printf

func Printf(format string, args ...interface{})

Printf writes a line with format

func Println

func Println(args ...interface{})

Println writes a line with colors

func Question

func Question(format string, args ...interface{}) error

Question prints a message with the question symbol first, and the text in magenta

func RedString

func RedString(format string, args ...interface{}) string

RedString returns a string in blue

func SetLevel

func SetLevel(level string)

SetLevel sets the level of the main logger

func SetOutput

func SetOutput(output io.Writer)

SetOutput sets the log output

func SetOutputFormat

func SetOutputFormat(format string)

SetOutputFormat sets the output format

func SetStage

func SetStage(stage string)

SetStage sets the stage of the logger

func Spinner

func Spinner(text string)

Spinner sets the text provided as Suffix and FinalMSG of the spinner instance

func StartSpinner

func StartSpinner()

StartSpinner starts to run the spinner if enabled or Println if not

func StopSpinner

func StopSpinner()

StopSpinner deletes FinalMSG and stops the running of the spinner

func Success

func Success(format string, args ...interface{})

Success prints a message with the success symbol first, and the text in green

func Warning

func Warning(format string, args ...interface{})

Warning prints a message with the warning symbol first, and the text in yellow

func Yellow

func Yellow(format string, args ...interface{})

Yellow writes a line in yellow

Types

type JSONLogFormat

type JSONLogFormat struct {
	Level     string `json:"level"`
	Stage     string `json:"stage"`
	Message   string `json:"message"`
	Timestamp int64  `json:"timestamp"`
}

JSONLogFormat formats the messages into json struct

func (*JSONLogFormat) Format

func (*JSONLogFormat) Format(entry *logrus.Entry) ([]byte, error)

Format formats the message

type JSONWriter

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

JSONWriter writes into a JSON terminal

func (*JSONWriter) AddToBuffer

func (w *JSONWriter) AddToBuffer(level, format string, a ...interface{})

AddToBuffer logs into the buffer and writes to stdout if its a json writer

func (*JSONWriter) Debug

func (w *JSONWriter) Debug(args ...interface{})

Debug writes a debug-level log

func (*JSONWriter) Debugf

func (*JSONWriter) Debugf(format string, args ...interface{})

Debugf writes a debug-level log with a format

func (*JSONWriter) Error

func (*JSONWriter) Error(args ...interface{})

Error writes a error-level log

func (*JSONWriter) Errorf

func (*JSONWriter) Errorf(format string, args ...interface{})

Errorf writes a error-level log with a format

func (*JSONWriter) FPrintln

func (w *JSONWriter) FPrintln(writer io.Writer, args ...interface{})

FPrintln prints a line with format

func (*JSONWriter) FWarning

func (*JSONWriter) FWarning(writer io.Writer, format string, args ...interface{})

FWarning prints a message with the warning symbol first, and the text in yellow

func (*JSONWriter) Fail

func (w *JSONWriter) Fail(format string, args ...interface{})

Fail prints a message with the error symbol first, and the text in red

func (*JSONWriter) Fatalf

func (*JSONWriter) Fatalf(format string, args ...interface{})

Fatalf writes a error-level log with a format

func (*JSONWriter) Fprintf

func (w *JSONWriter) Fprintf(writer io.Writer, format string, a ...interface{})

Fprintf prints a line with format

func (*JSONWriter) Green

func (w *JSONWriter) Green(format string, args ...interface{})

Green writes a line in green

func (*JSONWriter) Hint

func (w *JSONWriter) Hint(format string, args ...interface{})

Hint prints a message with the text in blue

func (*JSONWriter) Info

func (*JSONWriter) Info(args ...interface{})

Info writes a info-level log

func (*JSONWriter) Infof

func (*JSONWriter) Infof(format string, args ...interface{})

Infof writes a info-level log with a format

func (*JSONWriter) Information

func (w *JSONWriter) Information(format string, args ...interface{})

Information prints a message with the information symbol first, and the text in blue

func (*JSONWriter) IsInteractive

func (*JSONWriter) IsInteractive() bool

IsInteractive checks if the writer is interactive

func (*JSONWriter) Print

func (w *JSONWriter) Print(args ...interface{})

Print writes a line with colors

func (*JSONWriter) Printf

func (w *JSONWriter) Printf(format string, a ...interface{})

Printf writes a line with format

func (*JSONWriter) Println

func (w *JSONWriter) Println(args ...interface{})

Println writes a line with colors

func (*JSONWriter) Question

func (*JSONWriter) Question(_ string, _ ...interface{}) error

Question prints a message with the question symbol first, and the text in magenta

func (*JSONWriter) Success

func (w *JSONWriter) Success(format string, args ...interface{})

Success prints a message with the success symbol first, and the text in green

func (*JSONWriter) Warning

func (w *JSONWriter) Warning(format string, args ...interface{})

Warning prints a message with the warning symbol first, and the text in yellow

func (*JSONWriter) Write

func (w *JSONWriter) Write(p []byte) (n int, err error)

Write logs into the buffer but does not print anything

func (*JSONWriter) Yellow

func (w *JSONWriter) Yellow(format string, args ...interface{})

Yellow writes a line in yellow

type OktetoWriter

type OktetoWriter interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail(format string, args ...interface{})
	Fatalf(format string, args ...interface{})

	Yellow(format string, args ...interface{})
	Green(format string, args ...interface{})

	Success(format string, args ...interface{})
	Information(format string, args ...interface{})
	Question(format string, args ...interface{}) error
	Warning(format string, args ...interface{})
	FWarning(w io.Writer, format string, args ...interface{})
	Hint(format string, args ...interface{})

	Println(args ...interface{})
	FPrintln(w io.Writer, args ...interface{})
	Print(args ...interface{})
	Fprintf(w io.Writer, format string, a ...interface{})
	Printf(format string, a ...interface{})

	IsInteractive() bool
	AddToBuffer(level, format string, a ...interface{})

	Write(p []byte) (n int, err error)
}

OktetoWriter implements the interface of the writers

func GetOutputWriter

func GetOutputWriter() OktetoWriter

GetOutputWriter sets the output format

type PlainWriter

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

PlainWriter writes into a plain terminal

func (*PlainWriter) AddToBuffer

func (*PlainWriter) AddToBuffer(level, format string, a ...interface{})

AddToBuffer logs into the buffer but does not print anything

func (*PlainWriter) Debug

func (w *PlainWriter) Debug(args ...interface{})

Debug writes a debug-level log

func (*PlainWriter) Debugf

func (*PlainWriter) Debugf(format string, args ...interface{})

Debugf writes a debug-level log with a format

func (*PlainWriter) Error

func (*PlainWriter) Error(args ...interface{})

Error writes a error-level log

func (*PlainWriter) Errorf

func (*PlainWriter) Errorf(format string, args ...interface{})

Errorf writes a error-level log with a format

func (*PlainWriter) FPrintln

func (w *PlainWriter) FPrintln(writer io.Writer, args ...interface{})

FPrintln prints a line with format

func (*PlainWriter) FWarning

func (w *PlainWriter) FWarning(writer io.Writer, format string, args ...interface{})

FWarning prints a message with the warning symbol first, and the text in yellow into an specific writer

func (*PlainWriter) Fail

func (w *PlainWriter) Fail(format string, args ...interface{})

Fail prints a message with the error symbol first, and the text in red

func (*PlainWriter) Fatalf

func (*PlainWriter) Fatalf(format string, args ...interface{})

Fatalf writes a error-level log with a format

func (*PlainWriter) Fprintf

func (w *PlainWriter) Fprintf(writer io.Writer, format string, a ...interface{})

Fprintf prints a line with format

func (*PlainWriter) Green

func (w *PlainWriter) Green(format string, args ...interface{})

Green writes a line in green

func (*PlainWriter) Hint

func (w *PlainWriter) Hint(format string, args ...interface{})

Hint prints a message with the text in blue

func (*PlainWriter) Info

func (*PlainWriter) Info(args ...interface{})

Info writes a info-level log

func (*PlainWriter) Infof

func (*PlainWriter) Infof(format string, args ...interface{})

Infof writes a info-level log with a format

func (*PlainWriter) Information

func (w *PlainWriter) Information(format string, args ...interface{})

Information prints a message with the information symbol first, and the text in blue

func (*PlainWriter) IsInteractive

func (*PlainWriter) IsInteractive() bool

IsInteractive checks if the writer is interactive

func (*PlainWriter) Print

func (w *PlainWriter) Print(args ...interface{})

Print writes a line with colors

func (*PlainWriter) Printf

func (w *PlainWriter) Printf(format string, a ...interface{})

Printf writes a line with format

func (*PlainWriter) Println

func (w *PlainWriter) Println(args ...interface{})

Println writes a line with colors

func (*PlainWriter) Question

func (w *PlainWriter) Question(format string, args ...interface{}) error

Question prints a message with the question symbol first, and the text in magenta

func (*PlainWriter) Success

func (w *PlainWriter) Success(format string, args ...interface{})

Success prints a message with the success symbol first, and the text in green

func (*PlainWriter) Warning

func (w *PlainWriter) Warning(format string, args ...interface{})

Warning prints a message with the warning symbol first, and the text in yellow

func (*PlainWriter) Write

func (w *PlainWriter) Write(p []byte) (n int, err error)

Write logs into the buffer but does not print anything

func (*PlainWriter) Yellow

func (w *PlainWriter) Yellow(format string, args ...interface{})

Yellow writes a line in yellow

type SilentWriter

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

SilentWriter writes into a plain terminal

func (*SilentWriter) AddToBuffer

func (*SilentWriter) AddToBuffer(level, format string, a ...interface{})

AddToBuffer logs into the buffer but does not print anything

func (*SilentWriter) Debug

func (w *SilentWriter) Debug(args ...interface{})

Debug writes a debug-level log

func (*SilentWriter) Debugf

func (w *SilentWriter) Debugf(format string, args ...interface{})

Debugf writes a debug-level log with a format

func (*SilentWriter) Error

func (w *SilentWriter) Error(args ...interface{})

Error writes a error-level log

func (*SilentWriter) Errorf

func (w *SilentWriter) Errorf(format string, args ...interface{})

Errorf writes a error-level log with a format

func (*SilentWriter) FPrintln

func (w *SilentWriter) FPrintln(writer io.Writer, args ...interface{})

FPrintln prints a line with format

func (*SilentWriter) FWarning

func (w *SilentWriter) FWarning(writer io.Writer, format string, args ...interface{})

FWarning prints a message with the warning symbol first, and the text in yellow into an specific writer

func (*SilentWriter) Fail

func (w *SilentWriter) Fail(format string, args ...interface{})

Fail prints a message with the error symbol first, and the text in red

func (*SilentWriter) Fatalf

func (w *SilentWriter) Fatalf(format string, args ...interface{})

Fatalf writes a error-level log with a format

func (*SilentWriter) Fprintf

func (w *SilentWriter) Fprintf(writer io.Writer, format string, a ...interface{})

Fprintf prints a line with format

func (*SilentWriter) Green

func (w *SilentWriter) Green(format string, args ...interface{})

Green writes a line in green

func (*SilentWriter) Hint

func (w *SilentWriter) Hint(format string, args ...interface{})

Hint prints a message with the text in blue

func (*SilentWriter) Info

func (w *SilentWriter) Info(args ...interface{})

Info writes a info-level log

func (*SilentWriter) Infof

func (*SilentWriter) Infof(format string, args ...interface{})

Infof writes a info-level log with a format

func (*SilentWriter) Information

func (w *SilentWriter) Information(format string, args ...interface{})

Information prints a message with the information symbol first, and the text in blue

func (*SilentWriter) IsInteractive

func (*SilentWriter) IsInteractive() bool

IsInteractive checks if the writer is interactive

func (*SilentWriter) Print

func (w *SilentWriter) Print(args ...interface{})

Print writes a line with colors

func (*SilentWriter) Printf

func (w *SilentWriter) Printf(format string, a ...interface{})

Printf writes a line with format

func (*SilentWriter) Println

func (w *SilentWriter) Println(args ...interface{})

Println writes a line with colors

func (*SilentWriter) Question

func (w *SilentWriter) Question(format string, args ...interface{}) error

Question prints a message with the question symbol first, and the text in magenta

func (*SilentWriter) Success

func (w *SilentWriter) Success(format string, args ...interface{})

Success prints a message with the success symbol first, and the text in green

func (*SilentWriter) Warning

func (w *SilentWriter) Warning(format string, args ...interface{})

Warning prints a message with the warning symbol first, and the text in yellow

func (*SilentWriter) Write

func (w *SilentWriter) Write(p []byte) (n int, err error)

Write logs into the buffer but does not print anything

func (*SilentWriter) Yellow

func (w *SilentWriter) Yellow(format string, args ...interface{})

Yellow writes a line in yellow

type TTYWriter

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

TTYWriter writes into a tty terminal

func (*TTYWriter) AddToBuffer

func (*TTYWriter) AddToBuffer(level, format string, a ...interface{})

AddToBuffer logs into the buffer but does not print anything

func (*TTYWriter) Debug

func (w *TTYWriter) Debug(args ...interface{})

Debug writes a debug-level log

func (*TTYWriter) Debugf

func (*TTYWriter) Debugf(format string, args ...interface{})

Debugf writes a debug-level log with a format

func (*TTYWriter) Error

func (*TTYWriter) Error(args ...interface{})

Error writes a error-level log

func (*TTYWriter) Errorf

func (*TTYWriter) Errorf(format string, args ...interface{})

Errorf writes a error-level log with a format

func (*TTYWriter) FPrintln

func (w *TTYWriter) FPrintln(writer io.Writer, args ...interface{})

FPrintln prints a line with format

func (*TTYWriter) FWarning

func (w *TTYWriter) FWarning(writer io.Writer, format string, args ...interface{})

FWarning prints a message with the warning symbol first, and the text in yellow into an specific writer

func (*TTYWriter) Fail

func (w *TTYWriter) Fail(format string, args ...interface{})

Fail prints a message with the error symbol first, and the text in red

func (*TTYWriter) Fatalf

func (*TTYWriter) Fatalf(format string, args ...interface{})

Fatalf writes a error-level log with a format

func (*TTYWriter) Fprintf

func (w *TTYWriter) Fprintf(writer io.Writer, format string, a ...interface{})

Fprintf prints a line with format

func (*TTYWriter) Green

func (w *TTYWriter) Green(format string, args ...interface{})

Green writes a line in green

func (*TTYWriter) Hint

func (w *TTYWriter) Hint(format string, args ...interface{})

Hint prints a message with the text in blue

func (*TTYWriter) Info

func (*TTYWriter) Info(args ...interface{})

Info writes a info-level log

func (*TTYWriter) Infof

func (*TTYWriter) Infof(format string, args ...interface{})

Infof writes a info-level log with a format

func (*TTYWriter) Information

func (w *TTYWriter) Information(format string, args ...interface{})

Information prints a message with the information symbol first, and the text in blue

func (*TTYWriter) IsInteractive

func (*TTYWriter) IsInteractive() bool

IsInteractive checks if the writer is interactive

func (*TTYWriter) Print

func (w *TTYWriter) Print(args ...interface{})

Print writes a line with colors

func (*TTYWriter) Printf

func (w *TTYWriter) Printf(format string, a ...interface{})

Printf writes a line with format

func (*TTYWriter) Println

func (w *TTYWriter) Println(args ...interface{})

Println writes a line with colors

func (*TTYWriter) Question

func (w *TTYWriter) Question(format string, args ...interface{}) error

Question prints a message with the question symbol first, and the text in magenta

func (*TTYWriter) Success

func (w *TTYWriter) Success(format string, args ...interface{})

Success prints a message with the success symbol first, and the text in green

func (*TTYWriter) Warning

func (w *TTYWriter) Warning(format string, args ...interface{})

Warning prints a message with the warning symbol first, and the text in yellow

func (*TTYWriter) Write

func (w *TTYWriter) Write(p []byte) (n int, err error)

Write logs into the buffer but does not print anything

func (*TTYWriter) Yellow

func (w *TTYWriter) Yellow(format string, args ...interface{})

Yellow writes a line in yellow

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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