zap

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

CI Go Report Card GoDoc

zap

import "github.com/go-coldbrew/log/loggers/zap"

Package zap provides a BaseLogger implementation for uber/zap

Example

This example shows how to use the zap backend with JSON output.

package main

import (
	"context"

	"github.com/go-coldbrew/log"
	"github.com/go-coldbrew/log/loggers"
	"github.com/go-coldbrew/log/loggers/zap"
)

func main() {
	logger := zap.NewLogger(
		loggers.WithJSONLogs(true),
		loggers.WithCallerInfo(true),
	)
	log.SetLogger(log.NewLogger(logger))

	ctx := context.Background()
	log.Info(ctx, "msg", "request handled", "method", "POST", "latency_ms", 12)
}

Index

Constants

COLBREW_CALL_STACK_SIZE number stack frame involved between the logger call from application to zap call.

const COLBREW_CALL_STACK_SIZE = 3

func NewLogger

func NewLogger(options ...loggers.Option) loggers.BaseLogger

Generated by gomarkdoc

Documentation

Overview

Package zap provides a BaseLogger implementation for uber/zap

Example

This example shows how to use the zap backend with JSON output.

package main

import (
	"context"

	"github.com/go-coldbrew/log"
	"github.com/go-coldbrew/log/loggers"
	"github.com/go-coldbrew/log/loggers/zap"
)

func main() {
	logger := zap.NewLogger(
		loggers.WithJSONLogs(true),
		loggers.WithCallerInfo(true),
	)
	log.SetLogger(log.NewLogger(logger))

	ctx := context.Background()
	log.Info(ctx, "msg", "request handled", "method", "POST", "latency_ms", 12)
}

Index

Examples

Constants

View Source
const COLBREW_CALL_STACK_SIZE = 3

COLBREW_CALL_STACK_SIZE number stack frame involved between the logger call from application to zap call.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(options ...loggers.Option) loggers.BaseLogger

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL