zap_human

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 14 Imported by: 0

README

zap-human ⚡️🧍

zap-human is a uber-go/zap encoder for humans. It does not attempt to be performant, but readable, and is not intended for use in production environments.

Installing

Download the package:

$ go get -u github.com/heyvito/zap-human

Then, import it for side-effects:

package main

import (
	_ "github.com/heyvito/zap-human"
    "go.uber.org/zap"
    "go.uber.org/zap/zapcore"
)

Finally, configure your logger using "human" as the encoder:

func main() {
    config := zap.NewDevelopmentConfig()
    config.Encoding = "human"
    config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
    config.DisableCaller = true
    logger, err = config.Build()
	if err != nil {
		// ...
	}
	zap.ReplaceGlobals(logger)
}

Acknowledgments

zap-human is built on top of zap's JSONEncoder, and uses several portions of it. Portions are Copyright (c) 2016-2017 Uber Technologies, Inc.

LICENSE

zap-human is licensed under the same license as Uber's zap:

Copyright (c) 2016-2017 Uber Technologies, Inc.
Copyright (c) 2023 Victor Gama de Oliveira 

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GetBufferPool = _pool.Get
)

Functions

func NewHumanEncoder

func NewHumanEncoder(cfg zapcore.EncoderConfig) (zapcore.Encoder, error)

Types

type HumanEncoder

type HumanEncoder struct {
	*zapcore.EncoderConfig
	// contains filtered or unexported fields
}

func (*HumanEncoder) AddArray

func (h *HumanEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error

func (*HumanEncoder) AddBinary

func (h *HumanEncoder) AddBinary(key string, value []byte)

func (*HumanEncoder) AddBool

func (h *HumanEncoder) AddBool(key string, value bool)

func (*HumanEncoder) AddByteString

func (h *HumanEncoder) AddByteString(key string, value []byte)

func (*HumanEncoder) AddComplex128

func (h *HumanEncoder) AddComplex128(key string, value complex128)

func (*HumanEncoder) AddComplex64

func (h *HumanEncoder) AddComplex64(key string, value complex64)

func (*HumanEncoder) AddDuration

func (h *HumanEncoder) AddDuration(key string, value time.Duration)

func (*HumanEncoder) AddFloat32

func (h *HumanEncoder) AddFloat32(key string, value float32)

func (*HumanEncoder) AddFloat64

func (h *HumanEncoder) AddFloat64(key string, value float64)

func (*HumanEncoder) AddInt

func (h *HumanEncoder) AddInt(key string, value int)

func (*HumanEncoder) AddInt16

func (h *HumanEncoder) AddInt16(key string, value int16)

func (*HumanEncoder) AddInt32

func (h *HumanEncoder) AddInt32(key string, value int32)

func (*HumanEncoder) AddInt64

func (h *HumanEncoder) AddInt64(key string, value int64)

func (*HumanEncoder) AddInt8

func (h *HumanEncoder) AddInt8(key string, value int8)

func (*HumanEncoder) AddObject

func (h *HumanEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error

func (*HumanEncoder) AddReflected

func (h *HumanEncoder) AddReflected(key string, value interface{}) error

func (*HumanEncoder) AddString

func (h *HumanEncoder) AddString(key, value string)

func (*HumanEncoder) AddTime

func (h *HumanEncoder) AddTime(key string, value time.Time)

func (*HumanEncoder) AddUint

func (h *HumanEncoder) AddUint(key string, value uint)

func (*HumanEncoder) AddUint16

func (h *HumanEncoder) AddUint16(key string, value uint16)

func (*HumanEncoder) AddUint32

func (h *HumanEncoder) AddUint32(key string, value uint32)

func (*HumanEncoder) AddUint64

func (h *HumanEncoder) AddUint64(key string, value uint64)

func (*HumanEncoder) AddUint8

func (h *HumanEncoder) AddUint8(key string, value uint8)

func (*HumanEncoder) AddUintptr

func (h *HumanEncoder) AddUintptr(key string, value uintptr)

func (*HumanEncoder) AppendArray

func (h *HumanEncoder) AppendArray(marshaler zapcore.ArrayMarshaler) error

func (*HumanEncoder) AppendBool

func (h *HumanEncoder) AppendBool(b bool)

func (*HumanEncoder) AppendByteString

func (h *HumanEncoder) AppendByteString(bytes []byte)

func (*HumanEncoder) AppendComplex128

func (h *HumanEncoder) AppendComplex128(c complex128)

func (*HumanEncoder) AppendComplex64

func (h *HumanEncoder) AppendComplex64(c complex64)

func (*HumanEncoder) AppendDuration

func (h *HumanEncoder) AppendDuration(duration time.Duration)

func (*HumanEncoder) AppendFloat32

func (h *HumanEncoder) AppendFloat32(f float32)

func (*HumanEncoder) AppendFloat64

func (h *HumanEncoder) AppendFloat64(f float64)

func (*HumanEncoder) AppendInt

func (h *HumanEncoder) AppendInt(i int)

func (*HumanEncoder) AppendInt16

func (h *HumanEncoder) AppendInt16(i int16)

func (*HumanEncoder) AppendInt32

func (h *HumanEncoder) AppendInt32(i int32)

func (*HumanEncoder) AppendInt64

func (h *HumanEncoder) AppendInt64(i int64)

func (*HumanEncoder) AppendInt8

func (h *HumanEncoder) AppendInt8(i int8)

func (*HumanEncoder) AppendObject

func (h *HumanEncoder) AppendObject(marshaler zapcore.ObjectMarshaler) error

func (*HumanEncoder) AppendReflected

func (h *HumanEncoder) AppendReflected(value interface{}) error

func (*HumanEncoder) AppendString

func (h *HumanEncoder) AppendString(s string)

func (*HumanEncoder) AppendTime

func (h *HumanEncoder) AppendTime(t time.Time)

func (*HumanEncoder) AppendUint

func (h *HumanEncoder) AppendUint(u uint)

func (*HumanEncoder) AppendUint16

func (h *HumanEncoder) AppendUint16(u uint16)

func (*HumanEncoder) AppendUint32

func (h *HumanEncoder) AppendUint32(u uint32)

func (*HumanEncoder) AppendUint64

func (h *HumanEncoder) AppendUint64(u uint64)

func (*HumanEncoder) AppendUint8

func (h *HumanEncoder) AppendUint8(u uint8)

func (*HumanEncoder) AppendUintptr

func (h *HumanEncoder) AppendUintptr(u uintptr)

func (*HumanEncoder) Clone

func (h *HumanEncoder) Clone() zapcore.Encoder

func (*HumanEncoder) EncodeEntry

func (h *HumanEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)

func (*HumanEncoder) OpenNamespace

func (h *HumanEncoder) OpenNamespace(key string)

type Pool

type Pool[T any] struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool[T any](fn func() T) *Pool[T]

func (*Pool[T]) Get

func (p *Pool[T]) Get() T

func (*Pool[T]) Put

func (p *Pool[T]) Put(x T)

Jump to

Keyboard shortcuts

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