logger

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

README

go-logger

介绍

golang日志输出,输出到日志文件、输出到终端窗口。

使用说明
  1. main.go

    package main
    
    import (
    	"context"
    	logger "gitee.com/jishulangcom/go-logger"
    )
    
    func main(){
    	//logger.New("./app.log") // 输出到日志的文件
        logger.New("") // 输出到终端
    	defer logger.Close()
    
    	// 输出错误信息
    	logger.Error("技术狼")
    
    	// 带上链路日志ID
    	ctx := context.Background()
    	logger.ErrorfTrace(ctx, "jishulang.com")
    }
    
    2024-08-11 13:18:10(1723353490)	error	[test/logger_test.go:28]	技术狼
    2024-08-11 13:18:10(1723353490)	error	[test/logger_test.go:32]	jishulang.com	{"uber-trace-id": "0000000000000000"}
    
    {"lv":"error","ts":"2024-08-11 13:17:46(1723353466)","caller":"[test/logger_test.go:15]","msg":"技术狼"}
    {"lv":"error","ts":"2024-08-11 13:17:46(1723353466)","caller":"[test/logger_test.go:19]","msg":"jishulang.com","uber-trace-id":"0000000000000000"}
    
  2. 运行程序

    # 更新依赖
    go mod tidy
    
    # 运行main
    
引用的三方包
github.com/opentracing/opentracing-go v1.2.0
github.com/uber/jaeger-client-go v2.30.0+incompatible
go.uber.org/zap v1.21.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

func DPanic

func DPanic(args ...interface{})

func DPanicTrace

func DPanicTrace(ctx context.Context, args ...interface{})

func DPanicf

func DPanicf(template string, args ...interface{})

func DPanicfTrace

func DPanicfTrace(ctx context.Context, template string, args ...interface{})

func Debug

func Debug(args ...interface{})

func DebugTrace

func DebugTrace(ctx context.Context, args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func DebugfTrace

func DebugfTrace(ctx context.Context, template string, args ...interface{})

func Error

func Error(args ...interface{})

func ErrorTrace

func ErrorTrace(ctx context.Context, args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func ErrorfTrace

func ErrorfTrace(ctx context.Context, template string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalTrace

func FatalTrace(ctx context.Context, args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func FatalfTrace

func FatalfTrace(ctx context.Context, template string, args ...interface{})

func Info

func Info(args ...interface{})

func InfoTrace

func InfoTrace(ctx context.Context, args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func InfofTrace

func InfofTrace(ctx context.Context, template string, args ...interface{})

func New

func New(filename string)

func Panic

func Panic(args ...interface{})

func PanicTrace

func PanicTrace(ctx context.Context, args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func PanicfTrace

func PanicfTrace(ctx context.Context, template string, args ...interface{})

func Warn

func Warn(args ...interface{})

func WarnTrace

func WarnTrace(ctx context.Context, args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

func WarnfTrace

func WarnfTrace(ctx context.Context, template string, args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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