log

package
v0.0.0-...-b563d55 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Overview

Package log provides logging for apiserver.

Package log provides logging for apiserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogging

func ConfigureLogging(cfg *LoggingConfig) func()

ConfigureLogging configures the log output for API Server.

func Debug

func Debug(args ...interface{})

Debug uses fmt.Sprint to construct and log a message.

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses fmt.Sprintf to log a templated message.

func Error

func Error(args ...interface{})

Error uses fmt.Sprint to construct and log a message.

func Errorf

func Errorf(template string, args ...interface{})

Errorf uses fmt.Sprintf to log a templated message.

func Fatal

func Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func HTTPHandler

func HTTPHandler(handler http.Handler, withPayloads bool) http.Handler

HTTPHandler wraps a server-side HTTP handler for logging.

func Info

func Info(args ...interface{})

Info uses fmt.Sprint to construct and log a message.

func Infof

func Infof(template string, args ...interface{})

Infof uses fmt.Sprintf to log a templated message.

func OnHTTPClient

func OnHTTPClient(hc *http.Client, withPayloads bool)

OnHTTPClient attaches logging support to an HTTP Client.

func Warn

func Warn(args ...interface{})

Warn uses fmt.Sprint to construct and log a message.

func Warnf

func Warnf(template string, args ...interface{})

Warnf uses fmt.Sprintf to log a templated message.

func With

func With(args ...interface{}) *zap.SugaredLogger

With adds a variadic number of fields to the logging context. It accepts a mix of strongly-typed Field objects and loosely-typed key-value pairs. When processing pairs, the first element of the pair is used as the field key and the second as the field value.

For example,

 sugaredLogger.With(
   "hello", "world",
   "failure", errors.New("oh no"),
   Stack(),
   "count", 42,
   "user", User{Name: "alice"},
)

is the equivalent of

unsugared.With(
  String("hello", "world"),
  String("failure", "oh no"),
  Stack(),
  Int("count", 42),
  Object("user", User{Name: "alice"}),
)

Note that the keys in key-value pairs should be strings. In development, passing a non-string key panics. In production, the logger is more forgiving: a separate error is logged, but the key-value pair is skipped and execution continues. Passing an orphaned key triggers similar behavior: panics in development and errors in production.

func WithError

func WithError(err error) *zap.SugaredLogger

WithError returns logger with error.

func Writer

func Writer() *io.PipeWriter

Writer writes log entries at at info.

func WriterWithLevel

func WriterWithLevel(f func(args ...interface{})) *io.PipeWriter

WriterWithLevel writes log entries at a specific level.

Types

type LoggingConfig

type LoggingConfig struct {
	Level                   string
	Format                  string
	GCPProjectID            string
	StackDriverMetricPrefix string
	Production              bool
}

LoggingConfig holds the log configuration

Jump to

Keyboard shortcuts

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