modulepackage
0.1.1
Repository: https://github.com/confetti-framework/syslog.git
Documentation: pkg.go.dev
# README
Syslog
Syslog package provides logger that generates syslog messages as defined in RFC 5424.
Example Logger
package main
import (
"fmt"
"github.com/confetti-framework/syslog"
"os"
)
func main() {
buf := &bytes.Buffer{}
l := syslog.NewLogger(buf, syslog.USER, "hostname", "appName", "procid")
// without structured data
syslog.Info(l, "ImageUploaded", nil, "image uploaded by %s: %s", "username", "image.jpg")
// with structured data
sd := syslog.StructuredData{}
sd.Element("id1").Set("par1", "val1")
syslog.Error(l, "LoginFailed", sd, "login failed: %s", "username")
fmt.Print(buf.String())
// Output is similar to this:
// <14>1 2017-08-15T23:13:15.335+02:00 hostname appName procid ImageUploaded - image uploaded by username: image.jpg
// <11>1 2017-08-15T23:13:15.335+02:00 hostname appName procid LoginFailed [id1 par1="val1"] login failed: username
}
Example Writer
package main
import (
"github.com/confetti-framework/syslog"
"log"
"os"
)
func main() {
const msg = "Start HTTP server (addr=:8080)"
hostname := "laptop"
appName := "testapp"
procid := "123"
wrappedWriter := syslog.NewWriter(os.Stdout, syslog.USER|syslog.NOTICE, hostname, appName, procid)
logger := log.New(wrappedWriter, "", 0)
logger.Println(msg)
// Output is similar to this:
// <13>1 2017-08-15T23:13:15.33+02:00 laptop testapp 123 - - Start HTTP server (addr=:8080)
}
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewLogger returns a new syslog logger that writes to the specified io.Writer.
NewWriter wrappes another io.Writer and returns a new io.Writer that generates syslog messages as defined in RFC 5424 and writes them to the given io.Writer.
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
From /usr/include/sys/syslog.h.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
Logger generates syslog messages.
# Type aliases
No description provided by the author
SDElement represents a structured data element and consists name-value pairs.
StructuredData provides a mechanism to express information in a well defined, easily parseable and interpretable data format.