zaploki

package module
v0.0.0-...-d887cf0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 9 Imported by: 0

README

zaploki

This is a generic zap core implementation for loki, independent with loki client, there're some implementation of loki client out there that you can choose to work with.

Installation

$ go get github.com/cymonkey/zaploki

Usage

import (
    "github.com/cymonkey/zaploki"
)

func main() {
    zaploki.NewCore(NewWithDefaultConfig(&loki.Config{}))
}

License

MIT License, check LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFieldToString

func FromFieldToString(f zapcore.Field) string

func NewCore

func NewCore(lc LogHandler, lv zapcore.LevelEnabler) zapcore.Core

func NewCoreWithCreateLogger

func NewCoreWithCreateLogger(lc LogHandler, zapConfig zap.Config) (*zap.Logger, error)

Types

type Core

type Core struct {
	zapcore.LevelEnabler
	// contains filtered or unexported fields
}

func (*Core) Check

func (loki *Core) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry

func (*Core) Sync

func (loki *Core) Sync() error

func (*Core) With

func (loki *Core) With(fields []zapcore.Field) zapcore.Core

func (*Core) Write

func (loki *Core) Write(entry zapcore.Entry, fields []zapcore.Field) error

type EntryLike

type EntryLike interface {
	push.Entry
}

type LogHandler

type LogHandler interface {
	Sync() error
	Proceed(entry zapcore.Entry, fields []zapcore.Field) error
}

func NewHandler

func NewHandler[T any](c LokiClient[T], cfg SinkConfig) LogHandler

type LogLineBuilder

type LogLineBuilder func(zapEntry zapcore.Entry, logFields []zapcore.Field) string

type LokiClient

type LokiClient[Entry any] interface {
	Chan() chan<- Entry
	Stop()
}

type Sink

type Sink[T any] struct {
	LogHandler
	// Zap sink compatible
	zap.Sink
	// contains filtered or unexported fields
}

func (*Sink[T]) Close

func (s *Sink[T]) Close() error

func (*Sink[T]) Proceed

func (s *Sink[T]) Proceed(zapEntry zapcore.Entry, fields []zapcore.Field) error

func (*Sink[T]) Sync

func (s *Sink[T]) Sync() error

* * Zap sink implementation

func (*Sink[T]) Write

func (s *Sink[T]) Write(p []byte) (int, error)

Backward compatible, should not use if necessary

type SinkConfig

type SinkConfig struct {
	DynamicLabels  []string
	PrintFieldKey  bool
	LoglineBuilder LogLineBuilder
}

Jump to

Keyboard shortcuts

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