log

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	G = Get
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Level         string
	Format        string
	HideFilename  bool
	HideTimestamp bool
}

Config is the logger configuration

func AddFlags

func AddFlags(fs *pflag.FlagSet) *Config

AddFlags binds the logger configuration flags to the provided flag set and returns a config object that can return a configured logger by calling the Build() function.

func PersistentSetup added in v0.0.6

func PersistentSetup(cmd *cobra.Command) *Config

PersistentSetup set up the logger on the root command, adding the required flags and calling Build() in the command PreRunE function.

func (*Config) Build added in v0.0.7

func (c *Config) Build() (*Logger, error)

Build constructs a new logger from the config

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func Build

func Build(conf *Config) (*Logger, error)

Build builds a new logger from a config. If conf is nil, uses default configuration. This will set the root logger which is returned from G(). If you do not want to set the root logger you should use conf.Build() instead.

func Get

func Get() *Logger

Get returns the default configured logger. You may also use its shorter alias: @G()

func (*Logger) Named

func (l *Logger) Named(name string) *Logger

func (*Logger) NewMiddleware

func (l *Logger) NewMiddleware(next http.HandlerFunc) http.HandlerFunc

NewMiddleware returns an http middleware that logs requests

func (*Logger) With

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

func (*Logger) Write

func (l *Logger) Write(data []byte) (int, error)

implement io.Writer

Jump to

Keyboard shortcuts

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