syslog

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package syslog provides message notification integration for local or remote syslogs.

Usage:

package main

import (
    "context"
    "log"

    sl "log/syslog"

    "github.com/nikoksr/notify"
    "github.com/nikoksr/notify/service/syslog"
)

func main() {
    syslogSvc, err := syslog.New(sl.LOG_USER, "")
    if err != nil {
        log.Fatalf("syslog.New() failed: %v", err)
    }

    notify.UseServices(syslogSvc)

    err = notify.Send(context.Background(), "TEST", "Hello, World!")
    if err != nil {
        log.Fatalf("notify.Send() failed: %v", err)
    }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service encapsulates a syslog daemon writer.

func New

func New(priority syslog.Priority, tag string) (*Service, error)

New returns a new instance of a Service notification service. Parameter 'tag' is used as a log prefix and may be left empty, it has a fallback value.

func NewFromDial

func NewFromDial(network, raddr string, priority syslog.Priority, tag string) (*Service, error)

NewFromDial returns a new instance of a Service notification service. The underlying syslog writer establishes a connection to a log daemon by connecting to address raddr on the specified network. Parameter 'tag' is used as a log prefix and may be left empty, it has a fallback value. Calling NewFromDial with network and raddr being empty strings is equal in function to calling New directly.

func (*Service) Close

func (s *Service) Close() error

Close the underlying syslog writer.

func (*Service) Send

func (s *Service) Send(ctx context.Context, subject, message string) error

Send takes a message subject and a message body and sends them to all previously set channels. user used for sending the message has to be a member of the channel.

Jump to

Keyboard shortcuts

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