log

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 41

Documentation

Overview

* Apache License 2.0 * * Copyright (c) 2022, Austin Zhai * All rights reserved.

Index

Constants

View Source
const (
	Ldate         = 1 << iota // the date in the local time zone: 2009/01/23
	Ltime                     // the time in the local time zone: 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
	Lfuncname
	LstdFlags = Ldate | Ltime // initial values for the standard logger
)

These flags define which text to prefix to each log entry generated by the Logger. Bits are or'ed together to control what's printed. With the exception of the Lmsgprefix flag, there is no control over the order they appear (the order listed here) or the format they present (as described in the comments). The prefix is followed by a colon only when Llongfile or Lshortfile is specified. For example, flags Ldate | Ltime (or LstdFlags) produce,

2009/01/23 01:23:23 message

while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,

2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugf

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

func Error

func Error(v ...interface{})

func Errorf

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

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

func Info

func Info(v ...interface{})

func Infof

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

func Printf

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

func Println

func Println(level Level, v ...interface{})

func SetFlags

func SetFlags(flag int)

func SetLevel

func SetLevel(level Level)

func SetOutput

func SetOutput(out io.Writer)

func SetPrefix

func SetPrefix(prefix string)

func Trace

func Trace(v ...interface{})

func Tracef

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

func Warn

func Warn(v ...interface{})

func Warnf

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

Types

type Level

type Level int
const (
	LevelNull  Level = 0
	LevelTrace Level = 1
	LevelDebug Level = 2
	LevelInfo  Level = 3
	LevelWarn  Level = 4
	LevelError Level = 5
	LevelFatal Level = 6
)

func ParseLevel

func ParseLevel(levelS string) (Level, error)

type Log

type Log struct {
	// contains filtered or unexported fields
}
var (
	DefaultLog *Log

	ErrUnsupportedLogLevel = errors.New("unsupported log level")
)

func NewLog

func NewLog() *Log

func WithFlags

func WithFlags(flag int) *Log

func WithLevel

func WithLevel(level Level) *Log

func WithOutput

func WithOutput(out io.Writer) *Log

func (*Log) Debug

func (log *Log) Debug(v ...interface{})

func (*Log) Debugf

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

func (*Log) Error

func (log *Log) Error(v ...interface{})

func (*Log) Errorf

func (log *Log) Errorf(format string, v ...interface{})

func (*Log) Fatal

func (log *Log) Fatal(v ...interface{})

func (*Log) Fatalf

func (log *Log) Fatalf(format string, v ...interface{})

func (*Log) Info

func (log *Log) Info(v ...interface{})

func (*Log) Infof

func (log *Log) Infof(format string, v ...interface{})

func (*Log) Printf

func (log *Log) Printf(level Level, format string, v ...interface{})

func (*Log) Println

func (log *Log) Println(level Level, v ...interface{})

func (*Log) SetFlags

func (log *Log) SetFlags(flag int)

func (*Log) SetLevel

func (log *Log) SetLevel(level Level)

func (*Log) SetOutput

func (log *Log) SetOutput(out io.Writer)

func (*Log) SetPrefix

func (log *Log) SetPrefix(prefix string)

func (*Log) Trace

func (log *Log) Trace(v ...interface{})

func (*Log) Tracef

func (log *Log) Tracef(format string, v ...interface{})

func (*Log) Warn

func (log *Log) Warn(v ...interface{})

func (*Log) Warnf

func (log *Log) Warnf(format string, v ...interface{})

func (*Log) WithFlags

func (log *Log) WithFlags(flag int) *Log

func (*Log) WithLevel

func (log *Log) WithLevel(level Level) *Log

func (*Log) WithOutput

func (log *Log) WithOutput(out io.Writer) *Log

type Logger

type Logger interface {
	Trace(v ...interface{})
	Tracef(format string, v ...interface{})
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
}

Jump to

Keyboard shortcuts

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