Debian Codegraph @

gelf/writer.go

raw symbols SCIP
1 // Copyright 2012 SocialCode. All rights reserved.
2 // Use of this source code is governed by the MIT
3 // license that can be found in the LICENSE file.
4
5 package gelf
6
7 import (
8 "net"
9 )
10
11 type Writer interface {
12 Close() error
13 Write([]byte) (int, error)
14 WriteMessage(*Message) error
15 }
16
17 // Writer implements io.Writer and is used to send both discrete
18 // messages to a graylog2 server, or data from a stream-oriented
19 // interface (like the functions in log).
20 type GelfWriter struct {
21 addr string
22 conn net.Conn
23 hostname string
24 Facility string // defaults to current process name
25 proto string
26 }
27
28 // Close connection and interrupt blocked Read or Write operations
29 func (w *GelfWriter) Close() error {
30 if w.conn == nil {
31 return nil
32 }
33 return w.conn.Close()
34 }