Documentation ¶
Overview ¶
Package le_go provides a Golang client library for logging to logentries.com over a TCP connection.
it uses an access token for sending log events.
Index ¶
- type Logger
- func (logger *Logger) Close() error
- func (logger *Logger) Fatal(v ...interface{})
- func (logger *Logger) Fatalf(format string, v ...interface{})
- func (logger *Logger) Fatalln(v ...interface{})
- func (logger *Logger) Flags() int
- func (l *Logger) Flush()
- func (l *Logger) Output(calldepth int, s string, doAsync func())
- func (logger *Logger) Panic(v ...interface{})
- func (logger *Logger) Panicf(format string, v ...interface{})
- func (logger *Logger) Panicln(v ...interface{})
- func (logger *Logger) Prefix() string
- func (logger *Logger) Print(v ...interface{})
- func (logger *Logger) Printf(format string, v ...interface{})
- func (logger *Logger) Println(v ...interface{})
- func (logger *Logger) SetErrorOutput(errOutput io.Writer)
- func (logger *Logger) SetFlags(flag int)
- func (logger *Logger) SetPrefix(prefix string)
- func (logger *Logger) Write(p []byte) (n int, err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a Logentries logger, it holds the open TCP connection, access token, prefix and flags.
all Logger operations are thread safe and blocking, log operations can be invoked in a non-blocking way by calling them from a goroutine.
Example ¶
le, err := Connect("data.logentries.com:443", "XXXX-XXXX-XXXX-XXXX", 0, os.Stderr, 0) // replace with token if err != nil { panic(err) } defer le.Close() le.Println("another test message")
Output:
Example (Write) ¶
le, err := Connect("data.logentries.com:443", "XXXX-XXXX-XXXX-XXXX", 0, os.Stderr, 0) // replace with token if err != nil { panic(err) } defer le.Close() fmt.Fprintln(le, "another test message")
Output:
func Connect ¶
func Connect(host, token string, concurrentWrites int, errOutput io.Writer, calldepthOffset int) (*Logger, error)
Connect creates a new Logger instance and opens a TCP connection to logentries.com, The token can be generated at logentries.com by adding a new log, choosing manual configuration and token based TCP connection.
func (*Logger) Fatal ¶
func (logger *Logger) Fatal(v ...interface{})
Fatal is same as Print() but calls to os.Exit(1)
func (*Logger) Fatalln ¶
func (logger *Logger) Fatalln(v ...interface{})
Fatalln is same as Println() but calls to os.Exit(1)
func (*Logger) Output ¶
Taken with slight modification from src/log/log.go Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 3 plus a given offset. Output does the actual writing to the TCP connection
func (*Logger) Panic ¶
func (logger *Logger) Panic(v ...interface{})
Panic is same as Print() but calls to panic
func (*Logger) Panicln ¶
func (logger *Logger) Panicln(v ...interface{})
Panicln is same as Println() but calls to panic
func (*Logger) Println ¶
func (logger *Logger) Println(v ...interface{})
Println logs a message with a linebreak