ctxlog

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 13 Imported by: 1

README

ctxlog

Documentation

Index

Constants

View Source
const (
	Ldate         = 1 << iota                     // the date in the local time zone in RFC3339: 2009-01-23
	Ltime                                         // the time in the local time zone in RFC3339: 01:23:23
	Lmicroseconds                                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	Lmsgprefix                                    // move the "prefix" from the beginning of the line to before the message
	LstdFlags     = Ldate | Ltime | Lmicroseconds // initial values for the standard logger
)

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, fields Fields)

Debug writes the output for a debug level logging event.

func Error

func Error(ctx context.Context, msg string, fields Fields)

Error writes the output for an error level logging event.

func Fatal

func Fatal(v ...any)

Fatal is equivalent to Print() followed by a call to os.Exit(1).

func FatalContext

func FatalContext(ctx context.Context, msg string, fields Fields)

FatalContext writes the output for a fatal level logging event.

func Fatalf

func Fatalf(format string, v ...any)

Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

func Fatalln

func Fatalln(v ...any)

Fatalln is equivalent to Println() followed by a call to os.Exit(1).

func Flags

func Flags() int

Flags returns the output flags for the standard logger. The flag bits are Ldate, Ltime, and so on.

func Info

func Info(ctx context.Context, msg string, fields Fields)

Info writes the output for an info level logging event.

func Output

func Output(calldepth int, s string) error

Output writes the output for a logging event.

func Panic

func Panic(v ...any)

Panic is equivalent to Print() followed by a call to panic().

func PanicContext

func PanicContext(ctx context.Context, msg string, fields Fields)

PanicContext writes the output for an panic level logging event.

func Panicf

func Panicf(format string, v ...any)

Panicf is equivalent to Printf() followed by a call to panic().

func Panicln

func Panicln(v ...any)

Panicln is equivalent to Println() followed by a call to panic().

func Prefix

func Prefix() string

Prefix returns the output prefix for the standard logger.

func Print

func Print(v ...any)

Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.

func Printf

func Printf(format string, v ...any)

Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...any)

Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.

func SetFlags

func SetFlags(flag int)

SetFlags sets the output flags for the standard logger. The flag bits are Ldate, Ltime, and so on.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output destination for the standard logger.

func SetPrefix

func SetPrefix(prefix string)

SetPrefix sets the output prefix for the standard logger.

func Trace

func Trace(ctx context.Context, msg string, fields Fields)

Trace writes the output for a trace level logging event.

func Warn

func Warn(ctx context.Context, msg string, fields Fields)

Warn writes the output for a warn level logging event.

func With

func With(parent context.Context, fields Fields) context.Context

func Writer

func Writer() io.Writer

Writer returns the output destination for the standard logger.

Types

type Fields

type Fields map[string]any

type Level

type Level int

Level defines log levels.

const (
	// LevelDebug defines debug log level.
	LevelDebug Level = iota

	// LevelInfo defines info log level.
	LevelInfo

	// LevelWarn defines warn log level.
	LevelWarn

	// LevelError defines error log level.
	LevelError

	// LevelFatal defines fatal log level.
	LevelFatal

	// LevelPanic defines panic log level.
	LevelPanic

	// LevelNo defines an absent log level.
	LevelNo

	// LevelDisabled disables the logger.
	LevelDisabled

	// LevelTrace defines trace log level.
	LevelTrace Level = -1
)

func (Level) String

func (lv Level) String() string

type Logger

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

func Default

func Default() *Logger

Default returns the standard logger used by the package-level output functions.

func New

func New(out io.Writer, prefix string, flag int) *Logger

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, msg string, fields Fields)

Debug writes the output for a debug level logging event.

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, fields Fields)

Error writes the output for an error level logging event.

func (*Logger) Fatal

func (l *Logger) Fatal(v ...any)

Fatal is equivalent to l.Print() followed by a call to os.Exit(1).

func (*Logger) FatalContext

func (l *Logger) FatalContext(ctx context.Context, msg string, fields Fields)

FatalContext writes the output for a fatal level logging event.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...any)

Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).

func (*Logger) Fatalln

func (l *Logger) Fatalln(v ...any)

Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).

func (*Logger) Flags

func (l *Logger) Flags() int

Flags returns the output flags for the logger. The flag bits are Ldate, Ltime, and so on.

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, fields Fields)

Info writes the output for an info level logging event.

func (*Logger) Level

func (l *Logger) Level() Level

func (*Logger) Output

func (l *Logger) Output(calldepth int, s string) error

func (*Logger) OutputContext

func (l *Logger) OutputContext(ctx context.Context, calldepth int, level Level, msg string, fields Fields) error

Output writes the output for a logging event.

func (*Logger) Panic

func (l *Logger) Panic(v ...any)

Panic is equivalent to l.Print() followed by a call to panic().

func (*Logger) PanicContext

func (l *Logger) PanicContext(ctx context.Context, msg string, fields Fields)

PanicContext writes the output for an panic level logging event.

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...any)

Panicf is equivalent to l.Printf() followed by a call to panic().

func (*Logger) Panicln

func (l *Logger) Panicln(v ...any)

func (*Logger) Prefix

func (l *Logger) Prefix() string

Prefix returns the output prefix for the logger.

func (*Logger) Print

func (l *Logger) Print(v ...any)

Print calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Print.

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...any)

Printf calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Println

func (l *Logger) Println(v ...any)

Println calls l.OutputContext to print to the logger. Arguments are handled in the manner of fmt.Println.

func (*Logger) SetFlags

func (l *Logger) SetFlags(flag int)

SetFlags sets the output flags for the logger. The flag bits are Ldate, Ltime, and so on.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

SetPrefix sets the output prefix for the logger.

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, msg string, fields Fields)

Trace writes the output for a trace level logging event.

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, msg string, fields Fields)

Warn writes the output for a warn level logging event.

func (*Logger) Writer

func (l *Logger) Writer() io.Writer

Jump to

Keyboard shortcuts

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