/
logging.go
45 lines (38 loc) · 1.43 KB
/
logging.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*************************************************************************
* Copyright 2021 Gravwell, Inc. All rights reserved.
* Contact: <legal@gravwell.io>
*
* This software may be modified and distributed under the terms of the
* BSD 2-clause license. See the LICENSE file for details.
**************************************************************************/
package client
import (
"fmt"
)
type logMsg struct {
Body string
}
// AccessLogF submits a log message to the webserver at the Access log level.
func (c *Client) AccessLogF(format string, a ...interface{}) error {
s := fmt.Sprintf(format, a...)
msg := logMsg{Body: s}
return c.postStaticURL(loggingAccessUrl(), msg, nil)
}
// InfoLogF submits a log message to the webserver at the Info log level.
func (c *Client) InfoLogF(format string, a ...interface{}) error {
s := fmt.Sprintf(format, a...)
msg := logMsg{Body: s}
return c.postStaticURL(loggingInfoUrl(), msg, nil)
}
// WarnLogF submits a log message to the webserver at the Warn log level.
func (c *Client) WarnLogF(format string, a ...interface{}) error {
s := fmt.Sprintf(format, a...)
msg := logMsg{Body: s}
return c.postStaticURL(loggingWarnUrl(), msg, nil)
}
// ErrorLogF submits a log message to the webserver at the Error log level.
func (c *Client) ErrorLogF(format string, a ...interface{}) error {
s := fmt.Sprintf(format, a...)
msg := logMsg{Body: s}
return c.postStaticURL(loggingErrorUrl(), msg, nil)
}