Categorygo.elastic.co/ecszap
modulepackage
1.0.3
Repository: https://github.com/elastic/ecs-logging-go-zap.git
Documentation: pkg.go.dev

# README

Build Status

Elastic Common Schema (ECS) support for uber-go/zap logger

Use this library for automatically adding a minimal set of ECS fields to your logs, when using uber-go/zap.

Documentation

Ready to get started? Documentation is at elastic.co.

Test

go test ./...

Contribute

Create a Pull Request from your own fork.

Run ./lint.sh to update and format you changes before submitting.

Add new dependencies to the NOTICE.txt.

License

This software is licensed under the Apache 2 license.

# Functions

ECSCompatibleEncoderConfig takes an existing zapcore.EncoderConfig and sets ECS relevant configuration options to ECS conformant values.
EpochMicrosTimeEncoder encodes a given time in microseconds.
FullCallerEncoder serializes the file name, line and function from the caller in an ECS compliant way; serializing the full path of the file name using the underlying zapcore.EntryCaller.
NewCore creates a zapcore.Core that uses an ECS conformant JSON encoder.
NewDefaultEncoderConfig returns an EncoderConfig with default settings.
ShortCallerEncoder serializes the file name, line and function from the caller in an ECS compliant way; removing everything except the final directory from the file name by calling the underlying zapcore.EntryCaller TrimmedPath().
WrapCore wraps a core with ECS core functionality and returns a zapcore.Core.
WrapCoreOption returns a zap.Option, wrapping the underlying zapcore.Core.

# Structs

EncoderConfig exports all non ECS related configurable settings.

# Type aliases

CallerEncoder is equivalent to zapcore.CallerEncoder, except that its UnmarshalText method uses FullCallerEncoder and ShortCallerEncoder from this package instead, in order to encode callers in the ECS format.