2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-11-19 17:47:03 -05:00
|
|
|
|
|
|
|
package log
|
|
|
|
|
2021-12-23 18:33:54 -05:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
2020-03-20 18:13:41 -04:00
|
|
|
|
2022-01-03 04:28:52 -05:00
|
|
|
// ObjectVersion object version key/versionId
|
|
|
|
type ObjectVersion struct {
|
|
|
|
ObjectName string `json:"objectName"`
|
|
|
|
VersionID string `json:"VersionId,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-11-19 17:47:03 -05:00
|
|
|
// Args - defines the arguments for the API.
|
|
|
|
type Args struct {
|
2022-01-03 04:28:52 -05:00
|
|
|
Bucket string `json:"bucket,omitempty"`
|
|
|
|
Object string `json:"object,omitempty"`
|
|
|
|
VersionID string `json:"versionId,omitempty"`
|
|
|
|
Objects []ObjectVersion `json:"objects,omitempty"`
|
|
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
2018-11-19 17:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Trace - defines the trace.
|
|
|
|
type Trace struct {
|
2021-01-26 16:21:51 -05:00
|
|
|
Message string `json:"message,omitempty"`
|
|
|
|
Source []string `json:"source,omitempty"`
|
|
|
|
Variables map[string]interface{} `json:"variables,omitempty"`
|
2018-11-19 17:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// API - defines the api type and its args.
|
|
|
|
type API struct {
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
Args *Args `json:"args,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Entry - defines fields and values of each log entry.
|
|
|
|
type Entry struct {
|
2021-12-23 18:33:54 -05:00
|
|
|
DeploymentID string `json:"deploymentid,omitempty"`
|
|
|
|
Level string `json:"level"`
|
|
|
|
LogKind string `json:"errKind"`
|
|
|
|
Time time.Time `json:"time"`
|
|
|
|
API *API `json:"api,omitempty"`
|
|
|
|
RemoteHost string `json:"remotehost,omitempty"`
|
|
|
|
Host string `json:"host,omitempty"`
|
|
|
|
RequestID string `json:"requestID,omitempty"`
|
|
|
|
UserAgent string `json:"userAgent,omitempty"`
|
|
|
|
Message string `json:"message,omitempty"`
|
|
|
|
Trace *Trace `json:"error,omitempty"`
|
2018-11-19 17:47:03 -05:00
|
|
|
}
|
2020-03-20 18:00:44 -04:00
|
|
|
|
|
|
|
// Info holds console log messages
|
|
|
|
type Info struct {
|
|
|
|
Entry
|
|
|
|
ConsoleMsg string
|
|
|
|
NodeName string `json:"node"`
|
|
|
|
Err error `json:"-"`
|
|
|
|
}
|
2020-03-20 18:13:41 -04:00
|
|
|
|
|
|
|
// SendLog returns true if log pertains to node specified in args.
|
|
|
|
func (l Info) 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
|
|
|
|
}
|