mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Move etcd, logger, crypto into their own packages (#8366)
- Deprecates _MINIO_PROFILER, `mc admin profile` does the job - Move ENVs to common location in cmd/config/
This commit is contained in:
committed by
kannappanr
parent
bffc378a4f
commit
290ad0996f
86
cmd/logger/config.go
Normal file
86
cmd/logger/config.go
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2019 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package logger
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/minio/minio/pkg/env"
|
||||
)
|
||||
|
||||
// Console logger target
|
||||
type Console struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// HTTP logger target
|
||||
type HTTP struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
}
|
||||
|
||||
// Config console and http logger targets
|
||||
type Config struct {
|
||||
Console Console `json:"console"`
|
||||
HTTP map[string]HTTP `json:"http"`
|
||||
Audit map[string]HTTP `json:"audit"`
|
||||
}
|
||||
|
||||
// HTTP endpoint logger
|
||||
const (
|
||||
EnvLoggerHTTPEndpoint = "MINIO_LOGGER_HTTP_ENDPOINT"
|
||||
EnvAuditLoggerHTTPEndpoint = "MINIO_AUDIT_LOGGER_HTTP_ENDPOINT"
|
||||
)
|
||||
|
||||
// Default target name when no targets are found
|
||||
const (
|
||||
defaultTarget = "_"
|
||||
)
|
||||
|
||||
// LookupConfig - lookup logger config, override with ENVs if set.
|
||||
func LookupConfig(cfg Config) (Config, error) {
|
||||
envs := env.List(EnvLoggerHTTPEndpoint)
|
||||
for _, e := range envs {
|
||||
target := strings.TrimPrefix(e, EnvLoggerHTTPEndpoint)
|
||||
if target == "" {
|
||||
target = defaultTarget
|
||||
}
|
||||
_, ok := cfg.HTTP[target]
|
||||
if ok {
|
||||
cfg.HTTP[target] = HTTP{
|
||||
Enabled: true,
|
||||
Endpoint: env.Get(e, cfg.HTTP[target].Endpoint),
|
||||
}
|
||||
}
|
||||
}
|
||||
aenvs := env.List(EnvAuditLoggerHTTPEndpoint)
|
||||
for _, e := range aenvs {
|
||||
target := strings.TrimPrefix(e, EnvAuditLoggerHTTPEndpoint)
|
||||
if target == "" {
|
||||
target = defaultTarget
|
||||
}
|
||||
_, ok := cfg.Audit[target]
|
||||
if ok {
|
||||
cfg.Audit[target] = HTTP{
|
||||
Enabled: true,
|
||||
Endpoint: env.Get(e, cfg.Audit[target].Endpoint),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
@@ -28,14 +28,14 @@ import (
|
||||
"github.com/minio/minio/pkg/color"
|
||||
)
|
||||
|
||||
// Console interface describes the methods that need to be implemented to satisfy the interface requirements.
|
||||
type Console interface {
|
||||
// Logger interface describes the methods that need to be implemented to satisfy the interface requirements.
|
||||
type Logger interface {
|
||||
json(msg string, args ...interface{})
|
||||
quiet(msg string, args ...interface{})
|
||||
pretty(msg string, args ...interface{})
|
||||
}
|
||||
|
||||
func consoleLog(console Console, msg string, args ...interface{}) {
|
||||
func consoleLog(console Logger, msg string, args ...interface{}) {
|
||||
switch {
|
||||
case jsonFlag:
|
||||
// Strip escape control characters from json message
|
||||
|
||||
Reference in New Issue
Block a user