log

package
v0.0.0-...-46fbbb1 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug ...

func Debugf

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

Debugf ...

func Error

func Error(v ...interface{})

Error ...

func Errorf

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

Errorf ...

func Fatal

func Fatal(v ...interface{})

Fatal ...

func Fatalf

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

Fatalf ...

func Info

func Info(v ...interface{})

Info ...

func Infof

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

Infof ...

func Warning

func Warning(v ...interface{})

Warning ...

func Warningf

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

Warningf ...

Types

type Entry

type Entry struct {
	Time time.Time // time of the log produced
	Msg  string    // content of the entry
	Line string    // in which file and line that the log has been produced
	L    Level     // level of the log
}

func NewEntry

func NewEntry(time time.Time, msg, line string, l Level) *Entry

NewEntry creates an entry of journal with the args

type Formatter

type Formatter interface {
	Format(*Entry) ([]byte, error)
}

Formatter formats records in different ways: text, json, etc.

type Level

type Level int

Level ...

const (
	// DebugLevel debug
	DebugLevel Level = iota
	// InfoLevel info
	InfoLevel
	// WarningLevel warning
	WarningLevel
	// ErrorLevel error
	ErrorLevel
	// FatalLevel fatal
	FatalLevel
)

type Logger

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

Logger provides a struct with fields that describe the details of logger.

func New

func New(out io.Writer, formatter Formatter, lvl Level, options ...interface{}) *Logger

New returns a customized Logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

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

Debugf ...

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error ...

func (*Logger) Errorf

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

Errorf ...

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

Fatal ...

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf ...

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

Info ...

func (*Logger) Infof

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

Infof ...

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

SetOutput sets the output of Logger l

func (*Logger) Warning

func (l *Logger) Warning(v ...interface{})

Warning ...

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

Warningf ...

func (*Logger) WithDepth

func (l *Logger) WithDepth(depth int) *Logger

WithDepth returns cloned logger with new depth

type TextFormatter

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

TextFormatter represents a kind of formatter that formats the logs as plain text

func NewTextFormatter

func NewTextFormatter() *TextFormatter

NewTextFormatter returns a TextFormatter, the format of time is time.RFC3339

func (*TextFormatter) Format

func (t *TextFormatter) Format(e *Entry) (b []byte, err error)

Format formats the logs as "time [level] line message"

func (*TextFormatter) SetTimeFormat

func (t *TextFormatter) SetTimeFormat(fmt string)

SetTimeFormat sets time format of TextFormatter if the parameter fmt is not null

Jump to

Keyboard shortcuts

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