Created
January 7, 2016 17:20
-
-
Save hnakamur/75385e5572262b5ce9f6 to your computer and use it in GitHub Desktop.
go-syslog example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"gopkg.in/mcuadros/go-syslog.v2" | |
) | |
func main() { | |
channel := make(syslog.LogPartsChannel) | |
handler := syslog.NewChannelHandler(channel) | |
server := syslog.NewServer() | |
server.SetFormat(syslog.RFC5424) | |
server.SetHandler(handler) | |
server.ListenUDP("0.0.0.0:10514") | |
server.ListenTCP("0.0.0.0:10514") | |
server.Boot() | |
go func(channel syslog.LogPartsChannel) { | |
for logParts := range channel { | |
fmt.Println(logParts) | |
} | |
}(channel) | |
server.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
server
client
This example message are copied from RFC 5424 - The Syslog Protocol