Skip to content

Sunlight-Rim/zaptoseq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zap to Seq

A hook for sending Zap logs to Seq.

Documentation

Code documentation avaliable at godoc.

Usage

Import:

import zaptoseq "github.com/Sunlight-Rim/zaptoseq"


With one core:

    hook, err := zaptoseq.NewHook("http://localhost:5341", "token")
    if err != nil {
   	   panic(err)
    }

    log := hook.NewLogger(zap.NewDevelopmentConfig())

    log.Info("Hello, World!")

    hook.Wait()

Note: token can be an empty string.


With multiple cores:

    // Some Zap core
    stdoutCore := zapcore.NewCore(
        zapcore.NewConsoleEncoder(zap.NewProductionEncoderConfig()),
        zapcore.AddSync(os.Stdout),
        zapcore.DebugLevel,
    )

    hook, err := zaptoseq.NewHook("http://localhost:5341", "token")
    if err != nil {
   	   panic(err)
    }

    log := hook.NewLoggerWith(zap.NewDevelopmentConfig(), stdoutCore)

    // Will be sent to both Seq and stdout
    log.Info("Hello, World!")

    hook.Wait()


With multiple cores without DI:

    // Some Zap core
    stdoutCore := zapcore.NewCore(
        zapcore.NewConsoleEncoder(zap.NewProductionEncoderConfig()),
        zapcore.AddSync(os.Stdout),
        zapcore.DebugLevel,
    )

    hook, err := zaptoseq.NewHook("http://localhost:5341", "token")
    if err != nil {
   	   panic(err)
    }

    // Zap logger with Seq core and stdout core
    log := zap.New(zapcore.NewTee(
        stdoutCore,
        hook.NewCore(zap.NewDevelopmentConfig()),
    ), zap.AddCaller())

    // Will be sent to both Seq and stdout
    log.Info("Hello, World!")

    hook.Wait()

About

Go package for sending logs from Zap to Seq. No need of GELF.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%