log

package
v0.0.0-...-d99e7a5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...func(*zerolog.ConsoleWriter)) zerolog.Logger

New creates a new zerolog console logger, by default it uses RFC3339 as the time format.

Example
package main

import (
	"github.com/revett/common/log"
	zerolog "github.com/rs/zerolog/log"
)

func main() {
	zerolog.Logger = log.New(
		log.WithTimeFormat(""), log.WithNoColor(),
	)
	zerolog.Info().Msg("example")
}
Output:

INF example

Types

type NewFuncOption

type NewFuncOption func(*zerolog.ConsoleWriter)

NewFuncOption is a functional option for the New function.

func WithNoColor

func WithNoColor() NewFuncOption

WithNoColor is a functional option for the New function that disables colorized output for the logger.

func WithPrefix

func WithPrefix(p string) NewFuncOption

WithPrefix is a functional option for the New function that allows a prefix to be added to the logger.

Example
package main

import (
	"github.com/revett/common/log"
	zerolog "github.com/rs/zerolog/log"
)

func main() {
	zerolog.Logger = log.New(
		log.WithTimeFormat(""), log.WithNoColor(), log.WithPrefix("service"),
	)
	zerolog.Info().Msg("example")
}
Output:

INF service example

func WithTimeFormat

func WithTimeFormat(t string) NewFuncOption

WithTimeFormat is a functional option for the New function that allows a custom time format to be set for the logger.

Jump to

Keyboard shortcuts

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