go

πŸš€ Package Zapper (write logs but easier)

ja7ad

Javad Rajabzadeh

Posted on March 22, 2023

πŸš€ Package Zapper (write logs but easier)

Wrapping the zap log uber in the zapper package makes it easy to use zap to write logs to varianty core.

feature

  • available cores (console, file, sentry, json)
  • show stacktrace in log
  • log file rotation using lumberjack
  • create multiple core in same time
  • add service details to zapper
  • compatibility with ELK using json core
  • compatibility with some software architecture scenario
  • 100% compatibility with sentry using sentry core
package main

import (
    "github.com/GoFarsi/zapper"
    "log"
)

func main() {
    z := zapper.New(false, zapper.WithDebugLevel())
    if err := z.NewCore(
        zapper.ConsoleWriterCore(true),
        zapper.FileWriterCore("./test_data", nil),
    ); err != nil {
        log.Fatal(err)
    }

    z.Debug("debug log")
    z.Info("info log")
    z.Warn("warn log")
    z.Error("error log")
}
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/GoFarsi/zapper
Document: https://pkg.go.dev/github.com/GoFarsi/zapper

πŸ’– πŸ’ͺ πŸ™… 🚩
ja7ad
Javad Rajabzadeh

Posted on March 22, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related