2020-04-27 21:26:13 +08:00
|
|
|
package grlogs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ConsoleLogConfig struct {
|
2020-04-28 10:37:47 +08:00
|
|
|
Level Level `json:"level"`
|
2020-04-27 21:26:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ConsoleLogConfig) String() string {
|
|
|
|
b, _ := json.Marshal(c)
|
|
|
|
return bytes.NewBuffer(b).String()
|
|
|
|
}
|
|
|
|
|
|
|
|
type FileLogConfig struct {
|
|
|
|
Filename string `json:"filename"`
|
2020-04-28 10:37:47 +08:00
|
|
|
Level Level `json:"level"`
|
2020-04-27 21:26:13 +08:00
|
|
|
Maxlines int `json:"maxlines"`
|
|
|
|
Daily bool `json:"daily"`
|
|
|
|
Maxdays int `json:"maxdays"`
|
|
|
|
Color bool `json:"color"`
|
|
|
|
Rotate bool `json:"rotate"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *FileLogConfig) String() string {
|
|
|
|
b, _ := json.Marshal(c)
|
|
|
|
return bytes.NewBuffer(b).String()
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConnLogConfig struct {
|
|
|
|
ReconnectOnMsg bool `json:"reconnect_on_msg"`
|
|
|
|
Reconnect bool `json:"reconnect"`
|
|
|
|
Net string `json:"net"`
|
|
|
|
Addr string `json:"addr"`
|
2020-04-28 10:37:47 +08:00
|
|
|
Level Level `json:"level"`
|
2020-04-27 21:26:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ConnLogConfig) String() string {
|
|
|
|
b, _ := json.Marshal(c)
|
|
|
|
return bytes.NewBuffer(b).String()
|
|
|
|
}
|
|
|
|
|
|
|
|
type EsConfig struct {
|
2020-04-28 14:32:56 +08:00
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
Dsn string `json:"dsn"`
|
|
|
|
Level Level `json:"level"`
|
|
|
|
Index string `json:"index"`
|
2020-04-27 21:26:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *EsConfig) String() string {
|
|
|
|
b, _ := json.Marshal(c)
|
|
|
|
return bytes.NewBuffer(b).String()
|
|
|
|
}
|