Documentation ¶
Index ¶
- Constants
- Variables
- func AddAuditTarget(t Target) error
- func AddTarget(t Target) error
- func AuditLog(ctx context.Context, w http.ResponseWriter, r *http.Request, ...)
- func CriticalIf(ctx context.Context, err error, errKind ...interface{})
- func EnableAnonymous()
- func EnableJSON()
- func EnableQuiet()
- func Fatal(err error, msg string, data ...interface{})
- func FatalIf(err error, msg string, data ...interface{})
- func GetAuditEntry(ctx context.Context) *audit.Entry
- func Info(msg string, data ...interface{})
- func Init(goPath string, goRoot string)
- func IsJSON() bool
- func IsQuiet() bool
- func LogAlwaysIf(ctx context.Context, err error, errKind ...interface{})
- func LogIf(ctx context.Context, err error, errKind ...interface{})
- func LogOnceIf(ctx context.Context, err error, id interface{}, errKind ...interface{})
- func RegisterError(f func(string, error, bool) string)
- func SetAuditEntry(ctx context.Context, audit *audit.Entry) context.Context
- func SetDeploymentID(deploymentID string)
- func SetLoggerHTTP(scfg config.Config, k string, args HTTP)
- func SetLoggerHTTPAudit(scfg config.Config, k string, args HTTP)
- func SetReqInfo(ctx context.Context, req *ReqInfo) context.Context
- func StartupMessage(msg string, data ...interface{})
- type Config
- type Console
- type HTTP
- type KeyVal
- type Kind
- type Level
- type Logger
- type ReqInfo
- type ResponseWriter
- type Target
Constants ¶
const ( Endpoint = "endpoint" AuthToken = "auth_token" ClientCert = "client_cert" ClientKey = "client_key" EnvLoggerWebhookEnable = "MINIO_LOGGER_WEBHOOK_ENABLE" EnvLoggerWebhookEndpoint = "MINIO_LOGGER_WEBHOOK_ENDPOINT" EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN" EnvAuditWebhookEnable = "MINIO_AUDIT_WEBHOOK_ENABLE" EnvAuditWebhookEndpoint = "MINIO_AUDIT_WEBHOOK_ENDPOINT" EnvAuditWebhookAuthToken = "MINIO_AUDIT_WEBHOOK_AUTH_TOKEN" EnvAuditWebhookClientCert = "MINIO_AUDIT_WEBHOOK_CLIENT_CERT" EnvAuditWebhookClientKey = "MINIO_AUDIT_WEBHOOK_CLIENT_KEY" )
HTTP endpoint logger
const TimeFormat string = "15:04:05 MST 01/02/2006"
TimeFormat - logging time format.
Variables ¶
var ( DefaultKVS = config.KVS{ config.KV{ Key: config.Enable, Value: config.EnableOff, }, config.KV{ Key: Endpoint, Value: "", }, config.KV{ Key: AuthToken, Value: "", }, } DefaultAuditKVS = config.KVS{ config.KV{ Key: config.Enable, Value: config.EnableOff, }, config.KV{ Key: Endpoint, Value: "", }, config.KV{ Key: AuthToken, Value: "", }, config.KV{ Key: ClientCert, Value: "", }, config.KV{ Key: ClientKey, Value: "", }, } )
Default KVS for loggerHTTP and loggerAuditHTTP
var ( Help = config.HelpKVS{ config.HelpKV{ Key: Endpoint, Description: `HTTP(s) endpoint e.g. "http://localhost:8080/minio/logs/server"`, Type: "url", }, config.HelpKV{ Key: AuthToken, Description: `opaque string or JWT authorization token`, Optional: true, Type: "string", }, config.HelpKV{ Key: config.Comment, Description: config.DefaultComment, Optional: true, Type: "sentence", }, } HelpAudit = config.HelpKVS{ config.HelpKV{ Key: Endpoint, Description: `HTTP(s) endpoint e.g. "http://localhost:8080/minio/logs/audit"`, Type: "url", }, config.HelpKV{ Key: AuthToken, Description: `opaque string or JWT authorization token`, Optional: true, Type: "string", }, config.HelpKV{ Key: config.Comment, Description: config.DefaultComment, Optional: true, Type: "sentence", }, config.HelpKV{ Key: ClientCert, Description: "mTLS certificate for Audit Webhook authentication", Optional: true, Type: "string", }, config.HelpKV{ Key: ClientKey, Description: "mTLS certificate key for Audit Webhook authentication", Optional: true, Type: "string", }, } )
Help template for logger http and audit
var AuditTargets = []Target{}
AuditTargets is the list of enabled audit loggers
var BodyPlaceHolder = []byte("<BODY>")
BodyPlaceHolder returns a dummy body placeholder
var Disable = false
Disable disables all logging, false by default. (used for "go test")
var ErrCritical struct{}
ErrCritical is the value panic'd whenever CriticalIf is called.
var Targets = []Target{}
Targets is the set of enabled loggers
Functions ¶
func AddAuditTarget ¶
AddAuditTarget adds a new audit logger target to the list of enabled loggers
func AuditLog ¶
func AuditLog(ctx context.Context, w http.ResponseWriter, r *http.Request, reqClaims map[string]interface{}, filterKeys ...string)
AuditLog - logs audit logs to all audit targets.
func CriticalIf ¶
CriticalIf logs the provided error on the console. It fails the current go-routine by causing a `panic(ErrCritical)`.
func EnableAnonymous ¶
func EnableAnonymous()
EnableAnonymous - turns anonymous flag to avoid printing sensitive information.
func Fatal ¶
Fatal prints only fatal error message with no stack trace it will be called for input validation failures
func GetAuditEntry ¶
GetAuditEntry returns Audit entry if set.
func Init ¶
Init sets the trimStrings to possible GOPATHs and GOROOT directories. Also append github.com/zhaohuxing/minio This is done to clean up the filename, when stack trace is displayed when an error happens.
func LogAlwaysIf ¶
LogAlwaysIf prints a detailed error message during the execution of the server.
func LogIf ¶
LogIf prints a detailed error message during the execution of the server, if it is not an ignored error.
func LogOnceIf ¶
LogOnceIf - Logs notification errors - once per error. id is a unique identifier for related log messages, refer to cmd/notification.go on how it is used.
func RegisterError ¶
RegisterError registers the specified rendering function. This latter will be called for a pretty rendering of fatal errors.
func SetAuditEntry ¶
SetAuditEntry sets Audit info in the context.
func SetDeploymentID ¶
func SetDeploymentID(deploymentID string)
SetDeploymentID -- Deployment Id from the main package is set here
func SetLoggerHTTP ¶
SetLoggerHTTP helper for migrating older config to newer KV format.
func SetLoggerHTTPAudit ¶
SetLoggerHTTPAudit - helper for migrating older config to newer KV format.
func SetReqInfo ¶
SetReqInfo sets ReqInfo in the context.
Types ¶
type Config ¶
type Config struct { Console Console `json:"console"` HTTP map[string]HTTP `json:"http"` Audit map[string]HTTP `json:"audit"` }
Config console and http logger targets
func LookupConfig ¶
LookupConfig - lookup logger config, override with ENVs if set.
type HTTP ¶
type HTTP struct { Enabled bool `json:"enabled"` Endpoint string `json:"endpoint"` AuthToken string `json:"authToken"` ClientCert string `json:"clientCert"` ClientKey string `json:"clientKey"` }
HTTP logger target
type Logger ¶
type Logger interface {
// contains filtered or unexported methods
}
Logger interface describes the methods that need to be implemented to satisfy the interface requirements.
type ReqInfo ¶
type ReqInfo struct { RemoteHost string // Client Host/IP Host string // Node Host/IP UserAgent string // User Agent DeploymentID string // x-minio-deployment-id RequestID string // x-amz-request-id API string // API name - GetObject PutObject NewMultipartUpload etc. BucketName string // Bucket name ObjectName string // Object name AccessKey string // Access Key sync.RWMutex // contains filtered or unexported fields }
ReqInfo stores the request info.
func NewReqInfo ¶
func NewReqInfo(remoteHost, userAgent, deploymentID, requestID, api, bucket, object string) *ReqInfo
NewReqInfo :
func (*ReqInfo) AppendTags ¶
AppendTags - appends key/val to ReqInfo.tags
func (*ReqInfo) GetTagsMap ¶
GetTagsMap - returns the user defined tags in a map structure
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter StatusCode int // Log body of 4xx or 5xx responses LogErrBody bool // Log body of all responses LogAllBody bool TimeToFirstByte time.Duration StartTime time.Time // contains filtered or unexported fields }
ResponseWriter - is a wrapper to trap the http response status code.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
NewResponseWriter - returns a wrapped response writer to trap http status codes for auditing purposes.
func (*ResponseWriter) Flush ¶
func (lrw *ResponseWriter) Flush()
Flush - Calls the underlying Flush.
func (*ResponseWriter) Size ¶
func (lrw *ResponseWriter) Size() int
Size - reutrns the number of bytes written
func (*ResponseWriter) WriteHeader ¶
func (lrw *ResponseWriter) WriteHeader(code int)
WriteHeader - writes http status code