logger

package
v0.0.0-...-913b437 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logger provides a Writer implementation to be used for log.SetOutput to enable logging to both stderr and syslog.

Index

Constants

This section is empty.

Variables

View Source
var StartSyslog = func() {
	systemdAvail, err := utils.SystemdAvailable()
	if err != nil {
		log.Printf("Unable to decide if systemd is available: %v", err)
		return
	}
	var cmd []string
	if systemdAvail {
		cmd = []string{"systemctl", "start", "syslog"}
	} else {
		cmd = []string{"/etc/init.d/syslog", "start"}
	}
	utils.RunCommand(cmd, 30*time.Second)
}

StartSyslog runs the init script to start rsyslog or BusyBox syslog. rsyslog init has the `--oknodo flag` and will reliably return 0 if already started (common/recipes-extended/rsyslog/files/initscript). However, busybox syslog returns 1 if already started, so we ignore the error from RunCommand.

Functions

This section is empty.

Types

type LogWriter

type LogWriter struct {
	Streams []io.Writer
}

LogWriter is an implementation of io.Writer that will call write to all streams defined in Streams.

var CustomLogger LogWriter

CustomLogger is the output for flashy's logs to stderr and syslog

func (LogWriter) Write

func (w LogWriter) Write(p []byte) (n int, err error)

LogWriter implements io.Writer

Jump to

Keyboard shortcuts

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