journalr

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: AGPL-3.0 Imports: 6 Imported by: 1

README

Go Reference

journalr

This project provides a logr sink that writes log messages to the systemd journal. While normal log messages get written to the journal as text this sink also writes values of a log message as fields so they can be parsed later.

This project is released under GNU Affero General Public License v3.0, see LICENCE file in this repo for more info.

Documentation

Overview

Package journalr allows sending log messages to systemd journald via logr.Logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sink

type Sink struct {
	// contains filtered or unexported fields
}

Sink is a logr.LogSink that sends structured log messages to systemd journald.

func NewSink

func NewSink() (*Sink, error)

NewSink creates a new Sink for sending structured log messages to systemd journald.

func (Sink) Enabled

func (s Sink) Enabled(level int) bool

Enabled tests whether this LogSink is enabled at the specified V-level. For example, commandline flags might be used to set the logging verbosity and disable some info logs.

func (*Sink) Error

func (s *Sink) Error(err error, msg string, kvList ...interface{})

Error logs an error, with the given message and key/value pairs as context. See Logger.Error for more details.

func (*Sink) Info

func (s *Sink) Info(level int, msg string, kvList ...interface{})

Info logs a non-error message with the given key/value pairs as context. The level argument is provided for optional logging. This method will only be called when Enabled(level) is true. See Logger.Info for more details.

func (*Sink) Init

func (s *Sink) Init(info logr.RuntimeInfo)

Init receives optional information about the logr library for LogSink implementations that need it.

func (Sink) WithCallDepth

func (s Sink) WithCallDepth(depth int) logr.LogSink

WithCallDepth returns a LogSink that will offset the call stack by the specified number of frames when logging call site information.

If depth is 0, the LogSink should skip exactly the number of call frames defined in RuntimeInfo.CallDepth when Info or Error are called, i.e. the attribution should be to the direct caller of Logger.Info or Logger.Error.

If depth is 1 the attribution should skip 1 call frame, and so on. Successive calls to this are additive.

func (Sink) WithName

func (s Sink) WithName(name string) logr.LogSink

WithName returns a new LogSink with the specified name appended. See Logger.WithName for more details.

func (Sink) WithValues

func (s Sink) WithValues(newValues ...interface{}) logr.LogSink

WithValues returns a new LogSink with additional key/value pairs. See Logger.WithValues for more details.

Directories

Path Synopsis
cmd
mage
Package main contains the entry point for mage.
Package main contains the entry point for mage.

Jump to

Keyboard shortcuts

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