mirror of
https://github.com/pgsty/minio.git
synced 2026-07-21 05:00:22 +03:00
Allow logging targets to be configured to receive minio (#8347)
specific errors, `application` errors or `all` by default. console logging on server by default lists all logs - enhance admin console API to accept `type` as query parameter to subscribe to application/minio logs.
This commit is contained in:
@@ -76,7 +76,7 @@ type AMQPTarget struct {
|
||||
conn *amqp.Connection
|
||||
connMutex sync.Mutex
|
||||
store Store
|
||||
loggerOnce func(ctx context.Context, err error, id interface{})
|
||||
loggerOnce func(ctx context.Context, err error, id interface{}, errKind ...interface{})
|
||||
}
|
||||
|
||||
// ID - returns TargetID.
|
||||
@@ -215,7 +215,7 @@ func (target *AMQPTarget) Close() error {
|
||||
}
|
||||
|
||||
// NewAMQPTarget - creates new AMQP target.
|
||||
func NewAMQPTarget(id string, args AMQPArgs, doneCh <-chan struct{}, loggerOnce func(ctx context.Context, err error, id interface{})) (*AMQPTarget, error) {
|
||||
func NewAMQPTarget(id string, args AMQPArgs, doneCh <-chan struct{}, loggerOnce func(ctx context.Context, err error, id interface{}, errKind ...interface{})) (*AMQPTarget, error) {
|
||||
var conn *amqp.Connection
|
||||
var err error
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ type RedisTarget struct {
|
||||
pool *redis.Pool
|
||||
store Store
|
||||
firstPing bool
|
||||
loggerOnce func(ctx context.Context, err error, id interface{})
|
||||
loggerOnce func(ctx context.Context, err error, id interface{}, errKind ...interface{})
|
||||
}
|
||||
|
||||
// ID - returns target ID.
|
||||
@@ -222,7 +222,7 @@ func (target *RedisTarget) Close() error {
|
||||
}
|
||||
|
||||
// NewRedisTarget - creates new Redis target.
|
||||
func NewRedisTarget(id string, args RedisArgs, doneCh <-chan struct{}, loggerOnce func(ctx context.Context, err error, id interface{})) (*RedisTarget, error) {
|
||||
func NewRedisTarget(id string, args RedisArgs, doneCh <-chan struct{}, loggerOnce func(ctx context.Context, err error, id interface{}, errKind ...interface{})) (*RedisTarget, error) {
|
||||
pool := &redis.Pool{
|
||||
MaxIdle: 3,
|
||||
IdleTimeout: 2 * 60 * time.Second,
|
||||
|
||||
@@ -35,12 +35,14 @@ type LogInfo struct {
|
||||
}
|
||||
|
||||
// SendLog returns true if log pertains to node specified in args.
|
||||
func (l LogInfo) SendLog(node string) bool {
|
||||
return node == "" || strings.EqualFold(node, l.NodeName)
|
||||
func (l LogInfo) SendLog(node, logKind string) bool {
|
||||
nodeFltr := (node == "" || strings.EqualFold(node, l.NodeName))
|
||||
typeFltr := strings.EqualFold(logKind, "all") || strings.EqualFold(l.LogKind, logKind)
|
||||
return nodeFltr && typeFltr
|
||||
}
|
||||
|
||||
// GetLogs - listen on console log messages.
|
||||
func (adm AdminClient) GetLogs(node string, lineCnt int, doneCh <-chan struct{}) <-chan LogInfo {
|
||||
func (adm AdminClient) GetLogs(node string, lineCnt int, logKind string, doneCh <-chan struct{}) <-chan LogInfo {
|
||||
logCh := make(chan LogInfo, 1)
|
||||
|
||||
// Only success, start a routine to start reading line by line.
|
||||
@@ -49,6 +51,7 @@ func (adm AdminClient) GetLogs(node string, lineCnt int, doneCh <-chan struct{})
|
||||
urlValues := make(url.Values)
|
||||
urlValues.Set("node", node)
|
||||
urlValues.Set("limit", strconv.Itoa(lineCnt))
|
||||
urlValues.Set("logType", logKind)
|
||||
for {
|
||||
reqData := requestData{
|
||||
relPath: "/v1/log",
|
||||
|
||||
Reference in New Issue
Block a user