import "github.com/juju/rfc/rfc5424"
The rfc5424 package holds an implementation of a RFC 5424 syslog client along with types and functions that facilitate complying with the RFC.
client.go doc.go message.go priority.go structureddata.go util.go
const ProtocolVersion = 1
ProtocolVersion is the syslog protocol version implemented in this package.
AppName is the name of the originating app or device.
String is the RFC 5424 representation of the app name.
Validate ensures the that app name is correct.
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around a network connection to which syslog messages will be sent.
Open opens a syslog client to the given host address. If no dial func is provided then net.Dial is used.
Close closes the client's underlying connection.
Send sends the syslog message over the client's connection.
type ClientConfig struct { // MaxSize is the maximum allowed size for syslog messages sent // by the client. If not set then there is no maximum. MaxSize int // SendTImeout is the timeout that is used for each sent message. SendTimeout time.Duration }
ClientConfig is the configuration for a syslog client.
type Conn interface { io.Closer // Write writes the message to the connection. Write([]byte) (int, error) // SetWriteDeadline sets the absolute time after which any write // to the connection will time out. SetWriteDeadline(time.Time) error }
Conn is the subset of net.Conn needed for a syslog client.
DialFunc is a function that may be used to open a network connection.
TLSDialFunc returns a dial function that opens a TLS connection. If the address passed to the returned func does not include a port then the default syslog TLS port (6514) will be used.
Facility is the system component for which the log record was created.
const ( FacilityKern Facility FacilityUser // default FacilityMail FacilityDaemon FacilityAuth FacilitySyslog FacilityLPR FacilityNews FacilityUUCP FacilityCron FacilityAuthpriv FacilityFTP FacilityNTP FacilityLocal0 FacilityLocal1 FacilityLocal2 FacilityLocal3 FacilityLocal4 FacilityLocal5 FacilityLocal6 FacilityLocal7 )
These are the supported logging facilities.
String returns the name of the facility.
Validate ensures that the facility is correct.
type Header struct { Priority // Timestamp indicates when the record was originally created. Timestamp Timestamp // Hostname identifies the machine that originally sent the // syslog message. Hostname Hostname // AppName identifies the device or application that originated // the syslog message. AppName AppName // ProcID is a value that is included in the message, having no // interoperable meaning, except that a change in the value // indicates there has been a discontinuity in syslog reporting. // The field does not have any specific syntax or semantics; the // value is implementation-dependent and/or operator-assigned. ProcID ProcID // MsgID identifies the type of message. Messages with the same // MsgID should reflect events with the same semantics. The MSGID // itself is a string without further semantics. It is intended // for filtering messages on a relay or collector. MsgID MsgID }
Header holds the header portion of the log record.
String returns an RFC 5424 representation of the header.
Validate ensures that the header is correct.
type Hostname struct { // FQDN is a fully-qualified domain name. // // See RFC 1034. FQDN string // StaticIP is a statically-assigned IP address. // // See RFC 1035 or 4291-2.2. StaticIP net.IP // Hostname is an unqualified host name. Hostname string // DyanmicIP is a dynamically-assigned IP address. // // See RFC 1035 or 4291-2.2. DynamicIP net.IP }
Hostname hold the different possible values for an RFC 5424 value. The first non-empty field is the one that gets used.
String is the RFC 5424 representation of the hostname.
Validate ensures that the hostname is correct.
type Message struct { Header StructuredData // Msg is the record's UTF-8 message string. Msg string }
Message holds a single RFC-5424 log record.
See https://tools.ietf.org/html/rfc5424#section-6.
String returns the RFC 5424 representation of the log record.
Validate ensures that the record is correct.
MsgID identifies a syslog message type.
String is the RFC representation of the message ID.
Validate ensures that the message ID is correct.
type Priority struct { // Severity is the criticality of the log record. Severity Severity // Facility is the system component for which the log record // was created. Facility Facility }
Priority identifies the importance of a log record.
ParsePriority converts a priority string back into a Priority.
String returns the RFC 5424 representation of the priority.
Validated ensures that the priority is correct.
ProcID identifies a group of syslog messages.
String is the RFC representation of the proc ID.
Validate ensures that the proc ID is correct.
Severity is the criticality of the log record.
const ( SeverityEmergency Severity = iota SeverityAlert SeverityCrit SeverityError SeverityWarning SeverityNotice SeverityInformational SeverityDebug )
These are the supported logging severity levels.
String returns the name of the severity.
Validate ensures that the severity is correct. This will fail only in cases where an unsupported int is converted into a Severity.
type StructuredData []StructuredDataElement
StructuredData holds the structured data of a log record, if any.
func (sd StructuredData) String() string
String returns the RFC 5424 representation of the structured data.
func (sd StructuredData) Validate() error
Validate ensures that the structured data is correct.
type StructuredDataElement interface { // ID returns the "SD-ID" for the element. ID() StructuredDataName // Params returns all the elements items (if any), in order. Params() []StructuredDataParam // Validate ensures that the element is correct. Validate() error }
StructuredDataElement, AKA "SD-ELEMENT", provides the functionality that StructuredData needs from each of its elements.
StructuredDataName is a single name used in an element or its params.
func (sdn StructuredDataName) Validate() error
Validate ensures that the name is correct.
type StructuredDataParam struct { // Name identifies the item relative to an element. Note that an // element may have more than one item with the same name. Name StructuredDataName // Value is the value associated with the item. Value StructuredDataParamValue }
StructuredDataParam, AKA "SD-PARAM", is a single item in an element's list.
func (sdp StructuredDataParam) String() string
String returns the RFC 5424 representation of the item.
func (sdp StructuredDataParam) Validate() error
Validated ensures that the item is correct.
StructuredDataParamValue is the value of a single element item.
func (sdv StructuredDataParamValue) String() string
String returns the RFC 5424 representation of the value. In particular, it escapes \, ", and ].
func (sdv StructuredDataParamValue) Validate() error
Validate ensures that the value is correct.
Timestamp is an RFC 5424 timestamp.
String returns the RFC 5424 representation of the timestamp. In particular, this is RFC 3339 with some restrictions and a special case of "-" for the zero value.
Path | Synopsis |
---|---|
rfc5424test | Package rc5424test provides utilities for testing RFC 5424. |
sdelements | The sdelements package holds the implementations of the different RFC 5424 structured data elements. |
Package rfc5424 imports 8 packages (graph) and is imported by 23 packages. Updated 2018-05-14. Refresh now. Tools for package owners.