package log

import "github.com/envoyproxy/go-control-plane/pkg/log"

Package log provides a logging interface for use in this library.

Index

Examples

Types

type Logger

type Logger interface {
	// Debugf logs a formatted debugging message.
	Debugf(format string, args ...interface{})

	// Infof logs a formatted informational message.
	Infof(format string, args ...interface{})

	// Warnf logs a formatted warning message.
	Warnf(format string, args ...interface{})

	// Errorf logs a formatted error message.
	Errorf(format string, args ...interface{})
}

Logger interface for reporting informational and warning messages.

type LoggerFuncs

type LoggerFuncs struct {
	DebugFunc func(string, ...interface{})
	InfoFunc  func(string, ...interface{})
	WarnFunc  func(string, ...interface{})
	ErrorFunc func(string, ...interface{})
}

LoggerFuncs implements the Logger interface, allowing the caller to specify only the logging functions that are desired.

Example

Code:

{
	logger := log.Logger{}

	xdsLogger := LoggerFuncs{
		DebugFunc: logger.Printf,
		InfoFunc:  logger.Printf,
		WarnFunc:  logger.Printf,
		ErrorFunc: logger.Printf,
	}

	xdsLogger.Debugf("debug")
	xdsLogger.Infof("info")
	xdsLogger.Warnf("warn")
	xdsLogger.Errorf("error")
}

func (LoggerFuncs) Debugf

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

Debugf logs a formatted debugging message.

func (LoggerFuncs) Errorf

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

Errorf logs a formatted error message.

func (LoggerFuncs) Infof

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

Infof logs a formatted informational message.

func (LoggerFuncs) Warnf

func (f LoggerFuncs) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message.

Source Files

log.go

Version
v0.9.7
Published
Oct 1, 2020
Platform
js/wasm
Last checked
1 hour ago

Tools for package owners.