sdlogr

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 8 Imported by: 0

README

sdlogr: logr implementation

Another implementation of logr interface with addition of systemd specific prefixes (severity levels). This logger is meant for apps/services that are started via systemd and want to send their logs to the system journal.

logr.Info and logr.Error messages are prefixed by SD_INFO and SD_ERR respectively and therefor should be easy to distinguish and filter with journalctl command.

 // from systemd/sd-daemon.h
 #define SD_EMERG   "<0>"  /* system is unusable */
 #define SD_ALERT   "<1>"  /* action must be taken immediately */
 #define SD_CRIT    "<2>"  /* critical conditions */
 #define SD_ERR     "<3>"  /* error conditions */
 #define SD_WARNING "<4>"  /* warning conditions */
 #define SD_NOTICE  "<5>"  /* normal but significant condition */
 #define SD_INFO    "<6>"  /* informational */
 #define SD_DEBUG   "<7>"  /* debug-level messages */

Documentation

Overview

Package sdlogr: another implementation of logr interface with addition of systemd specific prefixes (severity levels). This logger is meant for apps/services that are started via systemd and want to send their logs to system journal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() logr.Logger

New returns a logr.Logger

func NewWithOptions

func NewWithOptions(opts Options) logr.Logger

NewWithOptions returns a logr.Logger

func UnmarshalStruct

func UnmarshalStruct(i interface{}) string

UnmarshalStruct converts struct to string (including keys) using "%+v" format

Types

type Options

type Options struct {
	// Depth biases the assumed number of call frames to the "true" caller.
	// Values less than zero will be treated as zero.
	Depth int

	// Verbosity tells sdlogr which V logs to produce.  Higher values enable
	// more logs.  Info logs at or below this level will be written, while logs
	// above this level will be discarded.
	Verbosity int

	// LogCallerInfo if this is false caller file name and line number will not be logged in logr.Info. Default is true, caller file name and line number are always logged in logr.Error.
	LogCallerInfo bool

	// Out where to send logs. Defaults to os.Stdout
	Out io.Writer
}

Jump to

Keyboard shortcuts

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