zerolog

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: BSD-3-Clause, MIT, MIT-0, + 2 more Imports: 7 Imported by: 0

README

log/zerolog - easy-config zerolog

go get -u "tawesoft.co.uk/go"
import "tawesoft.co.uk/go/log/zerolog"
Links License Stable?
homedocssrc MIT-0 candidate

About

Package log/zerolog makes it trivial to configure a zerolog logger with syslog, rotating file, and/or console output using the same uniform configuration interface.

See https://github.com/rs/zerolog

Log rotation provided by https://gopkg.in/natefinch/lumberjack.v2/

See https://www.tawesoft.co.uk/go/doc/log

Examples

package main

import (
    "time"

    "tawesoft.co.uk/go/log"
    "tawesoft.co.uk/go/log/zerolog"
)

func main() {
    cfg := log.Config{
        Syslog: log.ConfigSyslog{
            Enabled:  true,
            Network:  "", // local
            Address:  "", // local
            Priority: log.LOG_ERR | log.LOG_DAEMON,
            Tag:      "example",
        },
        File:   log.ConfigFile{
            Enabled:          true,
            Mode:             0600,
            Path:             "example.log",
            Rotate:           true,
            RotateCompress:   true,
            RotateMaxSize:    64 * 1024 * 1024, // 64MB
            RotateKeepAge:    30 * 24 * time.Hour,
            RotateKeepNumber: 32, // 32 * 64 MB = 2 GB max storage (before compression)
        },
        Stderr: log.ConfigStderr{
            Enabled: true,
            Color:   true,
        },
    }

    logger, closer, err := zerolog.New(cfg)
    if err != nil { panic(err) }
    defer closer()

    logger.Info().Msg("Hello world!")
}

Getting Help

This package is part of tawesoft.co.uk/go, a monorepo for small Go modules maintained by Tawesoft®. Check out that URL for more information about other Go modules from Tawesoft plus community and commercial support options.

Documentation

Overview

Package log/zerolog makes it trivial to configure a zerolog logger with syslog, rotating file, and/or console output using the same uniform configuration interface.

See https://github.com/rs/zerolog

Log rotation provided by https://gopkg.in/natefinch/lumberjack.v2/

See https://www.tawesoft.co.uk/go/doc/log

Examples

https://www.tawesoft.co.uk/go/doc/log/zerolog/examples/hello-world/

Package Information

License: MIT-0 (see LICENSE.txt)

Stable: candidate

For more information, documentation, source code, examples, support, links, etc. please see https://www.tawesoft.co.uk/go and https://www.tawesoft.co.uk/go/log/zerolog

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg log.Config) (logger zerolog.Logger, closer func() error, err error)

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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