Categorygithub.com/jeffzhangme/zapx
modulepackage
0.0.0-20230203034125-bdfd51f85d9b
Repository: https://github.com/jeffzhangme/zapx.git
Documentation: pkg.go.dev

# README

zapx

Based on uber-go/zap, log caching and redis/kafka sink implemented in Go

Doc

zapx ( Please read the uber-go/zap documentation first. )

Quick Start

Using redis sink

go get github.com/jeffzhangme/zapx
stderr := zapx.SinkURL{url.URL{Opaque: "stderr"}}
sinkUrl := zapx.SinkURL{url.URL{Scheme: zapx.SchemeRedis, Host: "127.0.0.1:6379", RawQuery: "db=0&type=list&key=log:for:test"}}
logger, _ := zapx.NewCachedLoggerConfig().AddSinks(stderr, sinkUrl).Build()
defer logger.Flush(nil)
logger.Info("key", zap.String("k", "v"))

Log example

{
    "key": {
        "level": "info",
        "ts": 1546572659.1465247,
        "k": "v"
    },
    "level": "info",
    "ts": 1546572659.1465852
}

# Functions

InitKafkaSink create kafka sink instance.
InitRedisSink init redis sink.
NewCachedLoggerConfig create logger config.

# Constants

DEV dev.
PROD prod.
No description provided by the author
No description provided by the author
TEST test.

# Variables

GetBufPool retrieves a buffer from the pool, creating one if necessary.

# Structs

CachedLogConfig cached log config.
CachedLogger cached logger.
CachedSugaredLogger cached logger struct.
SinkURL sink url.

# Type aliases

ENV env.
MultiError multiple error.