syslog

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 15 Imported by: 0

README

go-syslog-client

A syslog client for golang which give possibility to send syslog message to a remote syslog server in multiple ways:

  • HTTP
  • UDP
  • TCP
  • TCP over TLS
  • Multiples syslog servers at same time

Usage

package main

import (
    "github.com/ArthurHlt/go-syslog-client"
)

func main() {
    writer, err := syslog.NewWriter(
    // data will be sent in http to this url with POST params
	"https://my.http.server.com/receive",
	// data will be sent http with gzip compression
	"https://my.http.server.com/receive?in_gzip=true",
	// in tcp mode
	"tcp://my.syslog.server.com:514",
	// in tcp mode with a pool of 10 connections (there is no pool by default)
    "tcp://my.syslog.server.com:514?pool_size=10",
	// tcp over tls without verifying server certificate (not recommended)
	"tcp+tls://my.syslog.server.com:514?verify=false",
	// tcp over tls with verifying server certificate
	"tcp+tls://my.syslog.server.com:514?cert=path/to/a/ca/file",
	// in udp mode
    "udp://my.syslog.server.com:514",
    )
	if err != nil {
        panic(err)
    }
    // write a message
    writer.Write([]byte(`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] BOMAn application event log entry...`))
    // close the writer
    writer.Close()
}

Documentation

Index

Constants

View Source
const QueryInGzip = "in_gzip"

Variables

This section is empty.

Functions

func NewWriter

func NewWriter(addresses ...string) (io.WriteCloser, error)

Types

type HttpWriter

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

func HttpDial

func HttpDial(addr string) (*HttpWriter, error)

func (*HttpWriter) Close

func (t *HttpWriter) Close() error

func (*HttpWriter) Write

func (t *HttpWriter) Write(b []byte) (int, error)

type MultiWriter

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

func MultiDial

func MultiDial(addresses ...string) (*MultiWriter, error)

func (*MultiWriter) Close

func (t *MultiWriter) Close() error

func (*MultiWriter) Write

func (t *MultiWriter) Write(b []byte) (int, error)

type Writer

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

func Dial

func Dial(addr string) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

Close closes a connection to the syslog daemon.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write sends a log message to the syslog daemon.

func (*Writer) WriteString

func (w *Writer) WriteString(mes string) (int, error)

WriteString sends a log message to the syslog daemon.

type WriterPool added in v1.1.0

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

func NewWriterPool added in v1.1.0

func NewWriterPool(poolSize int, addr string) (*WriterPool, error)

func (*WriterPool) Close added in v1.1.0

func (w *WriterPool) Close() error

Close closes a connection to the syslog daemon.

func (*WriterPool) Write added in v1.1.0

func (w *WriterPool) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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