DEV Community

Javad Rajabzadeh for Gopher

Posted on

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

#go

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️