log

package
v3.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package log provides common log functions to the cli infrastructure.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DebugLogger will reveal debug info which can be internal; will not be part of public binary
	DebugLogger = log.New(os.Stdout, colorMaybe("[DEBUG] ", color.HiBlueString), log.Ldate|log.Ltime|log.Llongfile)
	// InfoLogger sends useful but verbose information. Only sends if severity is >= InfoLevel.
	InfoLogger = log.New(os.Stdout, "[INFO] ", log.Ldate|log.Ltime)
	// OutLogger sends an important output from execution of the command, intended for a user to read.
	OutLogger = log.New(os.Stdout, "", 0)
	// WarnLogger sends warnings to stderr.
	WarnLogger = log.New(os.Stderr, colorMaybe("[WARNING] ", color.YellowString), 0)
	// ErrorLogger sends errors to stderr.
	ErrorLogger = log.New(os.Stderr, colorMaybe("[ERROR] ", color.RedString), 0)
	// Severity can be set to restrict level of log messages.
	Severity = WarnLevel
)

Functions

func Debugf

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

Debugf calls Output to print to the DebugLogger. Arguments are handled in the manner of fmt.Printf.

func Debugln

func Debugln(v ...interface{})

Debugln calls Output to print to the DebugLogger. Arguments are handled in the manner of fmt.Println.

func DoneMsgln

func DoneMsgln(msg string)

DoneMsgln surrounds msg with helpful visual cues for the user to indicate completion of a task.

func Error

func Error(v ...interface{})

Error calls Output to print to the ErrorLogger. Arguments are handled in the manner of fmt.Print.

func Errorf

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

Errorf calls Output to print to the ErrorLogger. Arguments are handled in the manner of fmt.Printf.

func Infof

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

Infof calls Output to print to the InfoLogger. Arguments are handled in the manner of fmt.Printf.

func Infoln

func Infoln(v ...interface{})

Infoln calls Output to print to the InfoLogger. Arguments are handled in the manner of fmt.Println.

func Out

func Out(v ...interface{})

Out calls Output to print to the OutLogger. Arguments are handled in the manner of fmt.Print.

func Outf

func Outf(format string, v ...interface{})

Outf calls Output to print to the OutLogger. Arguments are handled in the manner of fmt.Printf.

func Outln

func Outln(v ...interface{})

Outln calls Output to print to the OutLogger. Arguments are handled in the manner of fmt.Println.

func Warnf

func Warnf(format string, v ...interface{})

Warnf calls Output to print to the WarnLogger. Arguments are handled in the manner of fmt.Printf.

func Warnln

func Warnln(v ...interface{})

Warnln calls Output to print to the WarnLogger. Arguments are handled in the manner of fmt.Println.

Types

type Level

type Level uint8

Level defines the supported log levels.

const (
	DebugLevel Level = iota // DebugLevel will be set if the debug version of the binary gets built.
	InfoLevel               // InfoLevel will be set if developer passes a verbose flag.
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
)

Levels are the currently defined log levels for the CLI.

Jump to

Keyboard shortcuts

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