vlog

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

vlog/

The vlog directory contains code related to logging. Logging is distinct from monitoring because:

  1. Logging is not queryable
  2. Logging is loosely structured

Documentation

Index

Constants

View Source
const (
	InfoLog    = "[INFO] "
	WarningLog = "[WARNING] "
	ErrorLog   = "[ERROR] "
	DebugLog   = "[DEBUG] "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Printer

type Printer struct {
	Log           logr.Logger
	LogToFileOnly bool
	// ForCli can indicate if vclusterops is called from vcluster cli or other clients
	ForCli bool
}

Printer is a wrapper for the logger API that handles dual logging to the log and stdout. It reimplements all of the APIs from logr but adds two additional members: one is for printing messages to stdout, and the other one is for identifying where the logger came from.

func (*Printer) Error

func (p *Printer) Error(err error, msg string, keysAndValues ...any)

Error displays an error message to the log.

func (*Printer) Info

func (p *Printer) Info(msg string, keysAndValues ...any)

Info displays an info message to the log.

func (*Printer) LogArgParse

func (p *Printer) LogArgParse(inputArgv *[]string)

log functions for specific cases.

func (*Printer) LogMaskedArgParse

func (p *Printer) LogMaskedArgParse(inputArgv []string)

log functions with masked params

func (*Printer) PrintError

func (p *Printer) PrintError(msg string, v ...any)

PrintError will display the given error message in the log. And if not logging to stdout, it will repeat the message to the console.

func (*Printer) PrintInfo

func (p *Printer) PrintInfo(msg string, v ...any)

PrintInfo will display the given message in the log. And if not logging to stdout, it will repeat the message to the console.

func (*Printer) PrintWarning

func (p *Printer) PrintWarning(msg string, v ...any)

PrintWarning will display the given warning message in the log. And if not logging to stdout, it will repeat the message to the console.

func (*Printer) PrintWithIndent

func (p *Printer) PrintWithIndent(msg string, v ...any)

PrintWithIndent prints message to console only with an indentation

func (*Printer) SetupOrDie

func (p *Printer) SetupOrDie(logFile string)

setupOrDie will setup the logging for vcluster CLI. One exit, p.Log will be set.

func (*Printer) V

func (p *Printer) V(level int) logr.Logger

V sets the logging level. Can be daisy-chained to produce a log message for a given level.

func (*Printer) WithName

func (p *Printer) WithName(logName string) Printer

WithName will construct a new printer with the logger set with an additional name. The new printer inherits state from the current Printer.

Jump to

Keyboard shortcuts

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