slog

package module
v0.0.0-...-e877332 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 6 Imported by: 1

README

slog

GoLang package slog provides alternative syslog client API. An internal syslog writer used to send messages to a syslog service with options to tune it.

slog is not an officially supported Google product.

Example

	// ...

        if f, err := slog.ParseFacility(syslogFacility); err != nil {
                slog.Err(err)
                os.Exit(exTempFail)
        } else {
                slog.Init(slog.WithFacility(f))
        }

	// ...

        slog.Info("Job ID: ", jobId)
        slog.Info("Message-Id: ", mime.GetHeader("Message-Id"))

	// ...

Documentation

Overview

Package slog provides alternative syslog client API. An internal syslog writer used to send messages to a syslog service with options to tune it.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert(v ...interface{})

Alert sends a syslog message with severity LOG_ALERT.

func Alertf

func Alertf(format string, v ...interface{})

Alertf sends a formatted syslog message with severity LOG_ALERT.

func Crit

func Crit(v ...interface{})

Crit sends a syslog message with severity LOG_CRIT.

func Critf

func Critf(format string, v ...interface{})

Critf sends a formatted syslog message with severity LOG_CRIT.

func Debug

func Debug(v ...interface{})

Debug sends a syslog message with severity LOG_DEBUG.

func Debugf

func Debugf(format string, v ...interface{})

Debugf sends a formatted syslog message with severity LOG_DEBUG.

func Emerg

func Emerg(v ...interface{})

Emerg sends a syslog message with severity LOG_EMERG.

func Emergf

func Emergf(format string, v ...interface{})

Emergf sends a formatted syslog message with severity LOG_EMERG.

func Err

func Err(v ...interface{})

Err sends a syslog message with severity LOG_ERR.

func Errf

func Errf(format string, v ...interface{})

Errf sends a formatted syslog message with severity LOG_ERR.

func Info

func Info(v ...interface{})

Info sends a syslog message with severity LOG_INFO.

func Infof

func Infof(format string, v ...interface{})

Infof sends a formatted syslog message with severity LOG_INFO.

func Init

func Init(opts ...Option) error

Init initializes or re-initializes internal syslog writer. It is expected to be safe to call this function from concurrent goroutines.

func Notice

func Notice(v ...interface{})

Notice sends a syslog message with severity LOG_NOTICE.

func Noticef

func Noticef(format string, v ...interface{})

Noticef sends a formatted syslog message with severity LOG_NOTICE.

func ParseFacility

func ParseFacility(facility string) (syslog.Priority, error)

ParseFacility converts string representation of a syslog facility into syslog.Priority value. The standard facilities as described by FreeBSD `man syslog' as of 12.0-RELEASE are recognised (LOG_DAEMON, LOG_USER, etc). Parsing is case insensitive and LOG_ prefix is optional and can be omitted.

func Warning

func Warning(v ...interface{})

Warning sends a syslog message with severity LOG_WARNING.

func Warningf

func Warningf(format string, v ...interface{})

Warningf sends a formatted syslog message with severity LOG_WARNING.

Types

type Option

type Option func(p *params)

func WithDial

func WithDial(network, raddr string) Option

WithTag is an option for Init to specify parameter syslog service connection. Both values will be passed to syslog.Dia, see corresponding documentation for more details. As of the time this text being written, an empty value of network parameter requests a connection over a UNIX socket to a local syslog service (raddr is ignored in this case). Alternatively network can be a string accepted by net.Dial.

func WithFacility

func WithFacility(facility syslog.Priority) Option

WithFacility is an option for Init which adjusts facility in outgoing syslog messages.

func WithTag

func WithTag(tag string) Option

WithTag is an option for Init which adjusts tag in outgoing syslog messages. Tag is passed directly to syslog.Dial, see corresponding documentation for more details.

Jump to

Keyboard shortcuts

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