mirror of https://github.com/status-im/consul.git
logging: remove unnecessary package vars
This commit is contained in:
parent
c6b29a8bba
commit
b847c035d0
|
@ -40,15 +40,8 @@ type Config struct {
|
||||||
LogRotateMaxFiles int
|
LogRotateMaxFiles int
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
// defaultRotateDuration is the default time taken by the agent to rotate logs
|
||||||
// defaultRotateDuration is the default time taken by the agent to rotate logs
|
const defaultRotateDuration = 24 * time.Hour
|
||||||
defaultRotateDuration = 24 * time.Hour
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
logRotateDuration time.Duration
|
|
||||||
logRotateBytes int
|
|
||||||
)
|
|
||||||
|
|
||||||
type LogSetupErrorFn func(string)
|
type LogSetupErrorFn func(string)
|
||||||
|
|
||||||
|
@ -86,26 +79,17 @@ func Setup(config Config, out io.Writer) (hclog.InterceptLogger, error) {
|
||||||
// Create a file logger if the user has specified the path to the log file
|
// Create a file logger if the user has specified the path to the log file
|
||||||
if config.LogFilePath != "" {
|
if config.LogFilePath != "" {
|
||||||
dir, fileName := filepath.Split(config.LogFilePath)
|
dir, fileName := filepath.Split(config.LogFilePath)
|
||||||
// If a path is provided but has no fileName a default is provided.
|
|
||||||
if fileName == "" {
|
if fileName == "" {
|
||||||
fileName = "consul.log"
|
fileName = "consul.log"
|
||||||
}
|
}
|
||||||
// Try to enter the user specified log rotation duration first
|
if config.LogRotateDuration == 0 {
|
||||||
if config.LogRotateDuration != 0 {
|
config.LogRotateDuration = defaultRotateDuration
|
||||||
logRotateDuration = config.LogRotateDuration
|
|
||||||
} else {
|
|
||||||
// Default to 24 hrs if no rotation period is specified
|
|
||||||
logRotateDuration = defaultRotateDuration
|
|
||||||
}
|
|
||||||
// User specified byte limit for log rotation if one is provided
|
|
||||||
if config.LogRotateBytes != 0 {
|
|
||||||
logRotateBytes = config.LogRotateBytes
|
|
||||||
}
|
}
|
||||||
logFile := &LogFile{
|
logFile := &LogFile{
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
logPath: dir,
|
logPath: dir,
|
||||||
duration: logRotateDuration,
|
duration: config.LogRotateDuration,
|
||||||
MaxBytes: logRotateBytes,
|
MaxBytes: config.LogRotateBytes,
|
||||||
MaxFiles: config.LogRotateMaxFiles,
|
MaxFiles: config.LogRotateMaxFiles,
|
||||||
}
|
}
|
||||||
if err := logFile.openNew(); err != nil {
|
if err := logFile.openNew(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue