-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.go
73 lines (61 loc) · 1.65 KB
/
log.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package go_ts3
// logadd `manage_scope, write_scope`
type TeamspeakLogLevel int
//noinspection GoUnusedConst
const (
TeamspeakLogLevelFatal TeamspeakLogLevel = 1
TeamspeakLogLevelError TeamspeakLogLevel = 2
TeamspeakLogLevelWarning TeamspeakLogLevel = 3
TeamspeakLogLevelInfo TeamspeakLogLevel = 4
)
type LogAddRequest struct {
LogLevel TeamspeakLogLevel `schema:"loglevel,required"`
LogMessage string `schema:"logmsg,required"`
}
func (c *TeamspeakHttpClient) LogAdd(request LogAddRequest) error {
return c.requestWithParams(
"logadd",
request,
nil,
)
}
// logview `manage_scope, write_scope, read_scope`
type Log struct {
FileSize int `json:"file_size,string"`
LogMessage string `json:"l"`
LastPosition int `json:"last_pos,string"`
}
type logViewRequest struct {
Lines int `schema:"lines,omitempty"`
Reverse int `schema:"reverse,omitempty"`
Instance int `schema:"instance,omitempty"`
BeginPos int `schema:"begin_pos,omitempty"`
}
func (c *TeamspeakHttpClient) logView(request logViewRequest) (*[]Log, error) {
var logs []Log
err := c.requestWithParams(
"logview",
request,
&logs,
)
if err != nil {
return nil, err
}
return &logs, nil
}
func (c *TeamspeakHttpClient) LogViewInstance(lines int, reverse bool, beginPos int) (*[]Log, error) {
return c.logView(logViewRequest{
Lines: lines,
Reverse: boolToInt(reverse),
Instance: 1,
BeginPos: beginPos,
})
}
func (c *TeamspeakHttpClient) LogViewVirtualServer(lines int, reverse bool, beginPos int) (*[]Log, error) {
return c.logView(logViewRequest{
Lines: lines,
Reverse: boolToInt(reverse),
Instance: 0,
BeginPos: beginPos,
})
}