zap

package module
v0.0.0-...-c0075a2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 7 Imported by: 3

README

log

The logging implemented byzap

Usage

import (
    "github.com/segmentfault/pacman/contrib/log/zap"
    "github.com/segmentfault/pacman/log"
)
    log.SetLogger(zap.NewLogger(log.ParseLevel(logLevel), zap.WithName(Name), zap.WithPath(logPath), zap.WithCallerFullPath()))
    log.Debug("test")
    log.Info("test")
    log.Warn("test")
    log.Error("test")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitZap

func InitZap(logConf LoggerConfig) *zap.Logger

InitZap init zap logger

Types

type LogOption

type LogOption func(*Logger)

func WithCallerFullPath

func WithCallerFullPath() LogOption

WithCallerFullPath log caller full path

func WithMaxAge

func WithMaxAge(maxAge time.Duration) LogOption

WithMaxAge set max age

func WithName

func WithName(name string) LogOption

WithName set file name

func WithPath

func WithPath(path string) LogOption

WithPath set file path

func WithRotationTime

func WithRotationTime(rotationTime time.Duration) LogOption

WithRotationTime set rotation time

func WithoutStd

func WithoutStd() LogOption

WithoutStd no output stdout

type Logger

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

Logger zap logger config

func NewLogger

func NewLogger(level log.Level, options ...LogOption) *Logger

NewLogger new zap logger

func (*Logger) Debug

func (z *Logger) Debug(v ...any)

Debug log

func (*Logger) Debugf

func (z *Logger) Debugf(format string, v ...any)

Debugf log

func (*Logger) Error

func (z *Logger) Error(v ...any)

Error log

func (*Logger) Errorf

func (z *Logger) Errorf(format string, v ...any)

Errorf log

func (*Logger) Info

func (z *Logger) Info(v ...any)

Info log

func (*Logger) Infof

func (z *Logger) Infof(format string, v ...any)

Infof log

func (*Logger) Warn

func (z *Logger) Warn(v ...any)

Warn log

func (*Logger) Warnf

func (z *Logger) Warnf(format string, v ...any)

Warnf log

type LoggerConfig

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

Jump to

Keyboard shortcuts

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