syslog

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Deprecated: Use github.com/go-kit/log/syslog instead.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSyslogLogger

func NewSyslogLogger(w SyslogWriter, newLogger func(io.Writer) log.Logger, options ...Option) log.Logger

NewSyslogLogger returns a new Logger which writes to syslog in syslog format. The body of the log message is the formatted output from the Logger returned by newLogger.

Example (DefaultPrioritySelector)
package main

import (
	"fmt"

	gosyslog "log/syslog"

	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/log/level"
	"github.com/go-kit/kit/log/syslog"
)

func main() {
	// Normal syslog writer
	w, err := gosyslog.New(gosyslog.LOG_INFO, "experiment")
	if err != nil {
		fmt.Println(err)
		return
	}

	// syslog logger with logfmt formatting
	logger := syslog.NewSyslogLogger(w, log.NewLogfmtLogger)
	logger.Log("msg", "info because of default")
	logger.Log(level.Key(), level.DebugValue(), "msg", "debug because of explicit level")
}
Output:

Types

type Option

type Option = syslog.Option

Option sets a parameter for syslog loggers.

func PrioritySelectorOption

func PrioritySelectorOption(selector PrioritySelector) Option

PrioritySelectorOption sets priority selector function to choose syslog priority.

type PrioritySelector

type PrioritySelector = syslog.PrioritySelector

PrioritySelector inspects the list of keyvals and selects a syslog priority.

type SyslogWriter

type SyslogWriter = syslog.SyslogWriter

SyslogWriter is an interface wrapping stdlib syslog Writer.

Jump to

Keyboard shortcuts

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