Categorygithub.com/GoFarsi/zapper
modulepackage
1.5.3
Repository: https://github.com/gofarsi/zapper.git
Documentation: pkg.go.dev

# README

zapper Go Reference Go Report Card

zapper is zap but customized with multi core and sentry support, zapper make easiest usage with zap logger.

Cores

  • Console Writer
  • Sentry Core
  • File Writer
  • Json Core

Install

$ go get -u github.com/GoFarsi/zapper

Example

  • Console writer core
package main

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

func main() {
	z := zapper.New(false, zapper.WithTimeFormat(zapper.RFC3339NANO))
	if err := z.NewCore(zapper.ConsoleWriterCore(true)); err != nil {
		log.Fatal(err)
	}

	z.Info("test info")
	z.Debug("debug level")
}
  • Sentry Core
package main

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

func main() {
	z := zapper.New(false)
	if err := z.NewCore(zapper.SentryCore(os.Getenv("DSN"), "test", zapper.DEVELOPMENT, nil)); err != nil {
		log.Fatal(err)
	}

	err(z)
}

func err(z zapper.Zapper) {
	z.Error("test error new")
}
  • File Writer Core
package main

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

func main() {
	z := zapper.New(true, zapper.WithDebugLevel())
	if err := z.NewCore(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")
}
  • Json Core
package main

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

func main() {
	z := zapper.New(true, zapper.WithDebugLevel(), zapper.WithServiceDetails(23, "zapper"))
	if err := z.NewCore(zapper.JsonWriterCore("./test_data", ".json", nil)); err != nil {
		log.Fatal(err)
	}

	z.Debug("debug log")
	z.Info("info log")
	z.Warn("warn log")
	z.Error("error log")
}
  • Multi 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")
}

Contributing

  1. Fork zapper repository
  2. Clone forked project
  3. create new branch from main
  4. change things in new branch
  5. then send Pull Request from your changes in new branch

# Packages

No description provided by the author

# Functions

ConsoleWriterCore create console writer for zapper to show log in console.
FileWriterCore write logs into file.
JsonWriterCore write logs with json format, fileExtension is for set output file extension json,log and etc.
New create new Zap object.
No description provided by the author
SentryCore send log into sentry service.
WithCustomStackTraceLevel set custom level for show stacktrace, min level warn.
WithDebugLevel enable debug level for logging.
WithServiceDetails set service name for zapper and show service name for log files.
WithTimeFormat set custom time format for zapper logs.

# Constants

No description provided by the author
Debug logs are typically voluminous, and are usually disabled in production.
DEVELOPMENT application environment.
DPanic logs are particularly important errors.
Error logs are high-priority.
Fatal logs a message, then calls os.Exit(1).
No description provided by the author
Info is the default logging priority.
ISO8601 serializes a time.Time to an ISO8601-formatted string with millisecond precision.
No description provided by the author
Panic logs a message, then panics.
PRODUCTION application environment.
RFC3339 serializes a time.Time to an RFC3339-formatted string.
RFC3339NANO serializes a time.Time to an RFC3339-formatted string with nanosecond precision.
No description provided by the author
Warn logs are more important than Info, but don't need individual human review.

# Structs

No description provided by the author
Rotation config log file rotation in log path.
SentryConfig for sentry core set custom configs.
No description provided by the author

# Interfaces

No description provided by the author
Core zapper base abstract.
No description provided by the author

# Type aliases

Level zapper levels.
No description provided by the author
No description provided by the author
TimeFormat set custom time format for zap log.