Documentation ¶
Overview ¶
The rfc5424 package holds an implementation of a RFC 5424 syslog client along with types and functions that facilitate complying with the RFC.
Index ¶
- Constants
- type AppName
- type Client
- type ClientConfig
- type Conn
- type DialFunc
- type Facility
- type Header
- type Hostname
- type Message
- type MsgID
- type Priority
- type ProcID
- type Severity
- type StructuredData
- type StructuredDataElement
- type StructuredDataName
- type StructuredDataParam
- type StructuredDataParamValue
- type Timestamp
Constants ¶
const ProtocolVersion = 1
ProtocolVersion is the syslog protocol version implemented in this package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppName ¶
type AppName string
AppName is the name of the originating app or device.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around a network connection to which syslog messages will be sent.
func Open ¶
func Open(host string, cfg ClientConfig, dial DialFunc) (*Client, error)
Open opens a syslog client to the given host address. If no dial func is provided then net.Dial is used.
type ClientConfig ¶
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 ¶
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.
type Facility ¶
type Facility int
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.
type Header ¶
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.
type Hostname ¶
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.
type Message ¶
type Message struct { Header StructuredData // Msg is the record's UTF-8 message string. Msg string }
Message holds a single RFC-5424 log record.
type MsgID ¶
type MsgID string
MsgID identifies a syslog message type.
type Priority ¶
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.
func ParsePriority ¶
ParsePriority converts a priority string back into a Priority.
type ProcID ¶
type ProcID string
ProcID identifies a group of syslog messages.
type Severity ¶
type Severity int
Severity is the criticality of the log record.
type StructuredData ¶
type StructuredData []StructuredDataElement
StructuredData holds the structured data of a log record, if any.
func (StructuredData) String ¶
func (sd StructuredData) String() string
String returns the RFC 5424 representation of the structured data.
func (StructuredData) Validate ¶
func (sd StructuredData) Validate() error
Validate ensures that the structured data is correct.
type StructuredDataElement ¶
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.
type StructuredDataName ¶
type StructuredDataName string
StructuredDataName is a single name used in an element or its params.
func (StructuredDataName) Validate ¶
func (sdn StructuredDataName) Validate() error
Validate ensures that the name is correct.
type StructuredDataParam ¶
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 (StructuredDataParam) String ¶
func (sdp StructuredDataParam) String() string
String returns the RFC 5424 representation of the item.
func (StructuredDataParam) Validate ¶
func (sdp StructuredDataParam) Validate() error
Validated ensures that the item is correct.
type StructuredDataParamValue ¶
StructuredDataParamValue is the value of a single element item.
func (StructuredDataParamValue) String ¶
func (sdv StructuredDataParamValue) String() string
String returns the RFC 5424 representation of the value. In particular, it escapes \, ", and ].
func (StructuredDataParamValue) Validate ¶
func (sdv StructuredDataParamValue) Validate() error
Validate ensures that the value is correct.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package rc5424test provides utilities for testing RFC 5424.
|
Package rc5424test provides utilities for testing RFC 5424. |
The sdelements package holds the implementations of the different RFC 5424 structured data elements.
|
The sdelements package holds the implementations of the different RFC 5424 structured data elements. |