log

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LevelTrace = Level(codersdk.LogLevelTrace)
	LevelDebug = Level(codersdk.LogLevelDebug)
	LevelInfo  = Level(codersdk.LogLevelInfo)
	LevelWarn  = Level(codersdk.LogLevelWarn)
	LevelError = Level(codersdk.LogLevelError)
)

Below constants are the same as their codersdk equivalents.

Variables

This section is empty.

Functions

func HijackLogrus

func HijackLogrus(lvl Level, callback func(entry *logrus.Entry))

HijackLogrus hijacks the logrus logger and calls the callback for each log entry. This is an abuse of logrus, the package that Kaniko uses, but it exposes no other way to obtain the log entries.

func ToLogrus

func ToLogrus(lvl Level) logrus.Level

func Writer

func Writer(logf Func) (io.Writer, func())

Writer returns an io.Writer that logs all writes in a separate goroutine. It is the responsibility of the caller to call the returned function to stop the goroutine.

Types

type Func

type Func func(l Level, msg string, args ...any)

func Coder

func Coder(ctx context.Context, coderURL *url.URL, token string) (logger Func, closer func(), err error)

Coder establishes a connection to the Coder instance located at coderURL and authenticates using token. It then establishes a dRPC connection to the Agent API and begins sending logs. If the version of Coder does not support the Agent API, it will fall back to using the PatchLogs endpoint. The closer is used to close the logger and to wait at most logSendGracePeriod for logs to be sent. Cancelling the context will close the logs immediately without waiting for logs to be sent.

func New

func New(w io.Writer, verbose bool) Func

New logs to the provided io.Writer.

func Wrap

func Wrap(fs ...Func) Func

Wrap wraps the provided LogFuncs into a single Func.

type Level

type Level string

func FromLogrus

func FromLogrus(lvl logrus.Level) Level

Jump to

Keyboard shortcuts

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