Help us shape the future of Go! Take the 2026 Go Developer Survey

logutils

package
v0.68.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ComponentKey names the part of a program that emitted a log line.
	ComponentKey = "cmp"
	// ServiceNameKey distinguishes programs that write to the shared log file.
	ServiceNameKey = "service_name"

	// ServiceNameCLI identifies the hive CLI.
	ServiceNameCLI = "hive-cli"
	// ServiceNameDesktop identifies Hive Desktop.
	ServiceNameDesktop = "hive-desktop"
)
View Source
const (
	DefaultMaxFileSize = 10 << 20
	DefaultFileBackups = 3
)

Variables

This section is empty.

Functions

func Component added in v0.60.0

func Component(logger zerolog.Logger, name string) zerolog.Logger

Component returns logger with the component label set to name. Give it a logger that has no component label yet: zerolog appends fields, so a second call adds a second cmp key instead of replacing the first.

func NewRoot added in v0.62.0

func NewRoot(opts Options) (zerolog.Logger, func(), error)

NewRoot builds a program's root logger. When File cannot be opened it returns the error and a logger over the remaining sinks. The cleanup is safe to call more than once.

func Service added in v0.62.0

func Service(logger zerolog.Logger, name string) zerolog.Logger

Service returns logger with the program identity set to name.

Types

type Options added in v0.62.0

type Options struct {
	Service string
	Level   zerolog.Level
	File    string
	Console io.Writer
	// JSON writers must not block.
	JSON  []io.Writer
	Hooks []zerolog.Hook
	// Zero means DefaultMaxFileSize and DefaultFileBackups; a negative
	// FileBackups truncates the file instead of keeping a backup.
	MaxFileSize int64
	FileBackups int
}

Jump to

Keyboard shortcuts

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