ulog

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: BSD-3-Clause Imports: 4 Imported by: 3

README

ulog

Go Reference License Build

ulog is a simple and efficient level logging library for Go

Getting Started

The ulog package can be added to a project with go get.

go get cattlecloud.net/go/ulog@latest
Examples
log := ulog.New("my/component")
log.E.Fmt("the level is %s", "error")
log.W.Fmt("the level is %s", "warn")
log.I.Fmt("the level is %s", "info")
log.D.Fmt("the level is %s", "debug")
log.T.Fmt("the level is %s", "trace")
Exclude timestamp

When running under systemd it is nice to not include the redundant timestamp directly from the logging package (since journald will already insert one). To exclude the timestamp simply set the ULOG_NOTIMESTAMP environment variable to true.

e.g. in a systemd unit file

[Service]
# ...
Environment="ULOG_NOTIMESTAMP=true"
License

The cattlecloud.net/go/ulog module is open source under the BSD-3-Clause license.

Documentation

Overview

Package ulog provides a lightweight and efficient leveled logging library for Go.

Index

Constants

View Source
const (
	Error = iota
	Warn
	Info
	Debug
	Trace
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	E Output // error logs
	W Output // warn logs
	I Output // info logs
	D Output // debug logs
	T Output // trace logs
	// contains filtered or unexported fields
}

func New

func New(name string, opts ...Option) *Log

type Option

type Option func(l *Log)

func SetLevel

func SetLevel(value int) Option

func SetNoTimestamp added in v1.1.1

func SetNoTimestamp() Option

type Output

type Output interface {
	Fmt(string, ...any)
}

Jump to

Keyboard shortcuts

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