Add GetGlobalConn
This commit is contained in:
parent
b83a572500
commit
ffb40d7843
11
global.go
11
global.go
|
|
@ -26,7 +26,7 @@ const (
|
|||
// error otherwise. It will attempt to establish a connection to the journal
|
||||
// if there is not already one in progress.
|
||||
func CheckConnection() error {
|
||||
_, err := getGlobal()
|
||||
_, err := GetGlobalConn()
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,12 @@ func SetGlobalConn(c *Conn) {
|
|||
global = c
|
||||
}
|
||||
|
||||
func getGlobal() (*Conn, error) {
|
||||
// GetGlobalConn returns the global (default) connection to the journal. It may
|
||||
// return an error if no connection could be established. If no connection is
|
||||
// yet established, it will attempt to establish one. This is rate limited to
|
||||
// avoid excessive connection attempts should there be a persistent problem
|
||||
// connecting to the journal socket.
|
||||
func GetGlobalConn() (*Conn, error) {
|
||||
globalLock.Lock()
|
||||
defer globalLock.Unlock()
|
||||
|
||||
|
|
@ -119,7 +124,7 @@ func SetGlobalErrHandler(errHandler func(err error)) {
|
|||
// Note: to avoid allocation / garbage, ensure attrs has capacity for an extra
|
||||
// 2+len(GlobalCommonAttr) values.
|
||||
func Entry(pri Priority, msg string, attrs []Attr) {
|
||||
c, _ := getGlobal()
|
||||
c, _ := GetGlobalConn()
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue