logger

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 5

README

logger

A logger that conforms to github.com/jcgregorio/slog.

Documentation

Overview

Major parts of this implementation are copied verbatim from https://github.com/golang/glog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger collects all the global state of the logging setup.

*Logger implements the slog.Logger interface.

func New

func New() *Logger

func NewFromOptions

func NewFromOptions(o *Options) *Logger

func (*Logger) Debug

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

func (*Logger) Debugf

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

func (*Logger) Error

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

func (*Logger) Errorf

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

func (*Logger) Fatal

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

func (*Logger) Fatalf

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

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) Raw

func (l *Logger) Raw(s string)

func (*Logger) Warning

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

func (*Logger) Warningf

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

type NopLogger

type NopLogger struct{}

NopLogger implements slog.Logger and does nothing.

func NewNopLogger

func NewNopLogger() *NopLogger

NewNopLogger returns an initialized *NopLogger.

func (*NopLogger) Debug

func (*NopLogger) Debug(args ...interface{})

Debug logs debugging logs. Arguments are handled in the manner of fmt.Print.

func (*NopLogger) Debugf

func (*NopLogger) Debugf(format string, args ...interface{})

Debugf logs debugging logs. Arguments are handled in the manner of fmt.Printf.

func (*NopLogger) Error

func (*NopLogger) Error(args ...interface{})

Error logs error logs. Arguments are handled in the manner of fmt.Print.

func (*NopLogger) Errorf

func (*NopLogger) Errorf(format string, args ...interface{})

Errorf logs error logs. Arguments are handled in the manner of fmt.Printf.

func (*NopLogger) Fatal

func (n *NopLogger) Fatal(args ...interface{})

Fatal logs a fatal log and then exits the program. Arguments are handled in the manner of fmt.Print.

func (*NopLogger) Fatalf

func (*NopLogger) Fatalf(format string, args ...interface{})

Fatalf logs a fatal log and then exits the program. Arguments are handled in the manner of fmt.Printf.

func (*NopLogger) Info

func (*NopLogger) Info(args ...interface{})

Info logs informational logs. Arguments are handled in the manner of fmt.Print.

func (*NopLogger) Infof

func (*NopLogger) Infof(format string, args ...interface{})

Infof logs informational logs. Arguments are handled in the manner of fmt.Printf.

func (*NopLogger) Raw

func (*NopLogger) Raw(s string)

Raw sends the string s to the logs without any additional formatting.

func (*NopLogger) Warning

func (*NopLogger) Warning(args ...interface{})

Warning logs warning logs. Arguments are handled in the manner of fmt.Print.

func (*NopLogger) Warningf

func (*NopLogger) Warningf(format string, args ...interface{})

Warning logs warning logs. Arguments are handled in the manner of fmt.Printf.

type Options

type Options struct {
	// SyncWriter is the destination to write logs to. If left nil then os.Stdout
	// will be used.
	SyncWriter SyncWriter

	// IncludeDebug is true will emit Debug/Debugf logs, otherwise those logs are ignored.
	IncludeDebug bool

	// DepthDelta is the number of extra stack levels to look up when reporting the calling function.
	//
	// Useful if Logger is going to be wrapped inside another logging module.
	DepthDelta int
}

Options is passed to NewFromOptions to control some aspects of the created Logger.

type SyncWriter

type SyncWriter interface {
	Write(p []byte) (n int, err error)
	Sync() error
}

Jump to

Keyboard shortcuts

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