ecszerolog

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 15

README

Elastic Common Schema (ECS) support for zerolog

Use this library for automatically adding a minimal set of ECS fields to your logs, when using zerolog.

Usage

package main

import (
	"os"

	"go.elastic.co/ecszerolog"
	"github.com/rs/zerolog/log"
)

func main() {
	logger := ecszerolog.New(os.Stdout)
	log.Logger = logger

	log.Info().Msg("Hello, World!")
}

Test

go test ./...

Contribute

Create a Pull Request from your own fork.

Run mage 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.

Documentation

Overview

Package ecszerolog provides a constructor to be used with the github.com/rs/zerolog logger library that helps creating Elastic Common Schema (ECS) conformant log entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(w io.Writer, options ...Option) zerolog.Logger

New will configure zerolog global options and return an ECS compliant logger.

All entries will have @timestamp and ecs.version attributes automatically added.

Types

type Option

type Option func(l zerolog.Logger) zerolog.Logger

Option indicates optional configuration that can be used when creating a logger.

func ErrorStack

func ErrorStack() Option

ErrorStack enables stack_trace output for supported errors.

currently supports: github.com/pkg/errors

func Level

func Level(level zerolog.Level) Option

Level will set the minimum accepted level by the logger.

func Origin

func Origin() Option

Origin is an option to add the log.origin attribute populated with file.name and file.line attributes in all entries.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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