Documentation ¶
Index ¶
- Constants
- Variables
- func AuditLog(ctx context.Context, w *ResponseWriter, r *http.Request, ...)
- func CriticalIf(ctx context.Context, err error, errKind ...interface{})
- func EnableAnonymous()
- func EnableJSON()
- func EnableQuiet()
- func Error(msg string, data ...interface{})
- func Fatal(err error, msg string, data ...interface{})
- func FatalIf(err error, msg string, data ...interface{})
- func GetAuditEntry(ctx context.Context) *audit.Entry
- func GetGlobalDeploymentID() string
- func Info(msg string, data ...interface{})
- func Init(goPath, goRoot string)
- func InitializeLogger(ctx context.Context, transport *http.Transport) error
- func IsAnonymous() bool
- 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 NewHTTPTransportWithClientCerts(parentTransport *http.Transport, clientCert, clientKey string) *http.Transport
- func RegisterError(f func(string, error, bool) string)
- func SetAuditEntry(ctx context.Context, audit *audit.Entry) context.Context
- func SetReqInfo(ctx context.Context, req *ReqInfo) context.Context
- func UpdateAuditWebhookTargets(cfg Config) error
- func UpdateSystemTargets(cfg Config) error
- type Config
- type KeyVal
- type Kind
- type Level
- type Logger
- type ObjectVersion
- type ReqInfo
- type ResponseWriter
- type Target
Constants ¶
const ( EnvLoggerJSONEnable = "CONSOLE_LOGGER_JSON_ENABLE" EnvLoggerAnonymousEnable = "CONSOLE_LOGGER_ANONYMOUS_ENABLE" EnvLoggerQuietEnable = "CONSOLE_LOGGER_QUIET_ENABLE" EnvGlobalDeploymentID = "CONSOLE_GLOBAL_DEPLOYMENT_ID" EnvLoggerWebhookEnable = "CONSOLE_LOGGER_WEBHOOK_ENABLE" EnvLoggerWebhookEndpoint = "CONSOLE_LOGGER_WEBHOOK_ENDPOINT" EnvLoggerWebhookAuthToken = "CONSOLE_LOGGER_WEBHOOK_AUTH_TOKEN" EnvLoggerWebhookClientCert = "CONSOLE_LOGGER_WEBHOOK_CLIENT_CERT" EnvLoggerWebhookClientKey = "CONSOLE_LOGGER_WEBHOOK_CLIENT_KEY" EnvLoggerWebhookQueueSize = "CONSOLE_LOGGER_WEBHOOK_QUEUE_SIZE" EnvAuditWebhookEnable = "CONSOLE_AUDIT_WEBHOOK_ENABLE" EnvAuditWebhookEndpoint = "CONSOLE_AUDIT_WEBHOOK_ENDPOINT" EnvAuditWebhookAuthToken = "CONSOLE_AUDIT_WEBHOOK_AUTH_TOKEN" EnvAuditWebhookClientCert = "CONSOLE_AUDIT_WEBHOOK_CLIENT_CERT" EnvAuditWebhookClientKey = "CONSOLE_AUDIT_WEBHOOK_CLIENT_KEY" EnvAuditWebhookQueueSize = "CONSOLE_AUDIT_WEBHOOK_QUEUE_SIZE" )
Audit/Logger constants
Variables ¶
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 (
GlobalContext context.Context
)
Functions ¶
func AuditLog ¶
func AuditLog(ctx context.Context, w *ResponseWriter, r *http.Request, reqClaims map[string]interface{}, filterKeys ...string)
AuditLog - logs audit logs to all audit targets.
func CriticalIf ¶
CriticalIf logs the provided errors 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 errors message with no stack trace it will be called for input validation failures
func GetAuditEntry ¶
GetAuditEntry returns Audit entry if set.
func Init ¶
func Init(goPath, goRoot string)
Init sets the trimStrings to possible GOPATHs and GOROOT directories. Also append github.com/minio/minio This is done to clean up the filename, when stack trace is displayed when an errors happens.
func InitializeLogger ¶
InitializeLogger :
func LogAlwaysIf ¶
LogAlwaysIf prints a detailed errors message during the execution of the server.
func LogOnceIf ¶
LogOnceIf - Logs notification errors - once per errors. id is a unique identifier for related log messages, refer to cmd/notification.go on how it is used.
func NewHTTPTransportWithClientCerts ¶
func NewHTTPTransportWithClientCerts(parentTransport *http.Transport, clientCert, clientKey string) *http.Transport
NewHTTPTransportWithClientCerts returns a new http configuration used while communicating with the cloud backends.
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 SetReqInfo ¶
SetReqInfo sets ReqInfo in the context.
func UpdateAuditWebhookTargets ¶
UpdateAuditWebhookTargets swaps audit webhook targets with newly loaded ones from the cfg
func UpdateSystemTargets ¶
UpdateSystemTargets swaps targets with newly loaded ones from the cfg
Types ¶
type Config ¶
type Config struct { HTTP map[string]http.Config `json:"http"` AuditWebhook map[string]http.Config `json:"audit"` }
Config console and http logger targets
func LookupConfigForSubSys ¶
LookupConfigForSubSys - lookup logger config, override with ENVs if set, for the given sub-system
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 ObjectVersion ¶
ObjectVersion object version key/versionId
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 SessionID string // custom session id API string // API name - GetObject PutObject NewMultipartUpload etc. BucketName string `json:",omitempty"` // Bucket name ObjectName string `json:",omitempty"` // Object name VersionID string `json:",omitempty"` // corresponding versionID for the object Objects []ObjectVersion `json:",omitempty"` // Only set during MultiObject delete handler. AccessKey string // Access Key sync.RWMutex // contains filtered or unexported fields }
ReqInfo stores the request info.
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
type Target ¶
type Target interface { String() string Endpoint() string Init() error Cancel() Send(entry interface{}, errKind string) error Type() types.TargetType }
Target is the entity that we will receive a single log entry and Send it to the log target e.g. Send the log to a http server
func AuditTargets ¶
func AuditTargets() []Target
AuditTargets returns active audit targets. Returned slice may not be modified in any way.
func SystemTargets ¶
func SystemTargets() []Target
SystemTargets returns active targets. Returned slice may not be modified in any way.