etcd: enable optional log file for embedded etcd log output
In this commit we add an extra config for enabling logging to an external file when using embedded etcd. This can be useful when running integration tests to see more details about etcd related issues.
This commit is contained in:
9 files changed
+23
-12
No files matched your search
+8
-3
@@ -60,8 +60,8 @@ func getFreePort() int {
|
||||
// NewEmbeddedEtcdInstance creates an embedded etcd instance for testing,
|
||||
// listening on random open ports. Returns the backend config and a cleanup
|
||||
// func that will stop the etcd instance.
|
||||
func NewEmbeddedEtcdInstance(path string, clientPort, peerPort uint16) (
|
||||
*Config, func(), error) {
|
||||
func NewEmbeddedEtcdInstance(path string, clientPort, peerPort uint16,
|
||||
logFile string) (*Config, func(), error) {
|
||||
|
||||
cfg := embed.NewConfig()
|
||||
cfg.Dir = path
|
||||
@@ -70,7 +70,12 @@ func NewEmbeddedEtcdInstance(path string, clientPort, peerPort uint16) (
|
||||
cfg.MaxTxnOps = 8192
|
||||
cfg.MaxRequestBytes = 16384 * 1024
|
||||
cfg.Logger = "zap"
|
||||
cfg.LogLevel = "error"
|
||||
if logFile != "" {
|
||||
cfg.LogLevel = "info"
|
||||
cfg.LogOutputs = []string{logFile}
|
||||
} else {
|
||||
cfg.LogLevel = "error"
|
||||
}
|
||||
|
||||
// Listen on random free ports if no ports were specified.
|
||||
if clientPort == 0 {
|
||||
|
||||
Reference in new issue
Block a user