log

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package log provides uniform logging and tracing interfaces for ntt. Other logging backends like Prometheus are hopefully easy to drop in.

Note this package provides a reduced set of log-levels. Especially Warning, Error, Fatal, Panic functions are missing:

  • Warning: Nobody reads warnings, because by definition nothing went wrong.
  • Error: If you choose to handle the error by logging it, by definition it’s not an error any more — you handled it. The act of logging an error handles the error, hence it is no longer appropriate to log it as an error.
  • Fatal/Panic: It is commonly accepted that libraries should not use panic, but if calling log.Fatal has the same effect, surely this should also be outlawed.

Taken from https://dave.cheney.net/2015/11/05/lets-talk-about-logging

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v0.14.0

func Close()

func Debug

func Debug(v ...interface{})

func Debugf

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

func Debugln

func Debugln(v ...interface{})

func Print

func Print(v ...interface{})

func Printf

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

func Println

func Println(v ...interface{})

func SetGlobalLevel

func SetGlobalLevel(level Level)

func SetGlobalLogger

func SetGlobalLogger(l Logger)

func Trace

func Trace(ctx context.Context, category string, v ...interface{})

func Tracef

func Tracef(ctx context.Context, category string, format string, v ...interface{})

func Traceln

func Traceln(ctx context.Context, category string, v ...interface{})

func Verbose

func Verbose(v ...interface{})

func Verbosef

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

func Verboseln

func Verboseln(v ...interface{})

Types

type ConsoleLogger

type ConsoleLogger struct {
	Out io.Writer
	// contains filtered or unexported fields
}

func (*ConsoleLogger) Output

func (l *ConsoleLogger) Output(level Level, s string) error

type ConsoleTracer

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

func (ConsoleTracer) End

func (t ConsoleTracer) End()

func (ConsoleTracer) Start

func (t ConsoleTracer) Start(ctx context.Context, spanName string) (context.Context, Span)

type Level

type Level int
const (
	DisabledLevel Level = iota
	PrintLevel
	VerboseLevel
	DebugLevel
	TraceLevel
)

func GlobalLevel

func GlobalLevel() Level

type Logger

type Logger interface {
	Output(Level, string) error
}

type Span

type Span interface {
	End()
}

type Tracer

type Tracer interface {
	// Start a span
	Start(ctx context.Context, spanName string) (context.Context, Span)
}

Jump to

Keyboard shortcuts

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