ecslogger

package
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCore

NewCore creates a zapcore.Core that uses an ECS conformant JSON encoder. This is the safest way to create an ECS compatible core.

func NewError

func NewError(err error) zapcore.ObjectMarshaler

func WrapCore

func WrapCore(c zapcore.Core) zapcore.Core

WrapCore wraps a core with ECS core functionality and returns a zapcore.Core. For ECS compatibility, ensure that the wrapped zapcore.Core uses an encoder that is created from an ECS compatible configuration. For further details check out ecszap.EncoderConfig or ecszap.ECSCompatibleEncoderConfig.

func WrapCoreOption

func WrapCoreOption() zap.Option

WrapCoreOption returns a zap.Option, wrapping the underlying zapcore.Core.

Types

type Config

type Config struct {
	Service ServiceConfig
	Console bool
	Path    string
	Level   zapcore.Level
}

type ILogger

type ILogger interface {
	Fatal(msg string, err error, fields ...zap.Field)
	Error(msg string, err error, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Debug(msg string, fields ...zap.Field)
	Log(level zapcore.Level, msg string, fields ...zap.Field)
	Println(args ...interface{})
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logs to a file following ElasticSearch ECS standard. It is compatible with pkg/errors and eris error libraries. It can also print to console depending on the values passed to Init

func New

func New(config Config) (Logger, error)

New returns a configured Logger.

serviceId must distinctly identify the service that is using the logger. If the service runs in multiple nodes, the serviceId should be the same for all. For example an indexer for SEC filings running on 10 nodes, can have "indexer_sec" as id across all instances.

serviceName is just a readable name for the service that will be added to logs.

Logs to logPath. If logPath is empty or logToConsole is true, then it logs to console.

func (Logger) Debug added in v0.8.7

func (l Logger) Debug(msg string, fields ...zap.Field)

func (Logger) Error

func (l Logger) Error(msg string, err error, fields ...zap.Field)

func (Logger) Fatal

func (l Logger) Fatal(msg string, err error, fields ...zap.Field)

func (Logger) Info

func (l Logger) Info(msg string, fields ...zap.Field)

func (Logger) Log

func (l Logger) Log(level zapcore.Level, msg string, fields ...zap.Field)

func (Logger) Println

func (l Logger) Println(args ...interface{})

type ServiceConfig

type ServiceConfig struct {
	Id   string
	Name string
}

Jump to

Keyboard shortcuts

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