Mark McLoughlin
fcc29894c2
config: multiple logging fixes
...
First, don't panic with invalid --log-outputs. For example:
$> ./bin/etcd --log-outputs foo
2018-12-20 15:05:47.988652 C | embed: unknown log-output "foo" (only supports "default", "stderr", "stdout")
panic: unknown log-output "foo" (only supports "default", "stderr", "stdout")
goroutine 1 [running]:
go.etcd.io/etcd/vendor/github.com/coreos/pkg/capnslog.(*PackageLogger).Panicf(0xc000294b00, 0x10fe067, 0x30, 0xc0001fa398, 0x4, 0x4)
go.etcd.io/etcd/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go:75 +0x161
go.etcd.io/etcd/embed.(*Config).setupLogging(0xc000291400, 0xc0002a85b0, 0x1)
go.etcd.io/etcd/embed/config_logging.go:120 +0x1939
...
Or:
$> ./bin/etcd --log-outputs foo,default --logger zap
panic: multi logoutput for "default" is not supported yet
goroutine 1 [running]:
go.etcd.io/etcd/embed.(*Config).setupLogging(0xc000314500, 0xc0001b2f70, 0x1)
go.etcd.io/etcd/embed/config_logging.go:129 +0x2437
go.etcd.io/etcd/embed.(*Config).Validate(0xc000314500, 0xc000268a98, 0x127e440)
go.etcd.io/etcd/embed/config.go:543 +0x43
Second, don't exit in embed.setupLogging(). Before:
$> ./bin/etcd --log-outputs foo,bar
--logger=capnslog supports only 1 value in '--log-outputs', got ["bar" "foo"]
and after:
$> ./bin/etcd --log-outputs foo,bar
2018-12-20 15:10:24.317982 E | etcdmain: error verifying flags, --logger=capnslog supports only 1 value in '--log-outputs', got ["bar" "foo"]. See 'etcd --help'.
Third, remove duplicated unique strings code. UniqueStringsFromFlag()
is already available to return a sorted slice of values, so just use
that.
Lastly, fix a tiny logging typo in config.
2019-01-17 15:09:26 -05:00
Gyuho Lee
15fcd6d599
embed: do not support "--log-outputs=default" for zap logger
...
systemd/journal should be configured manually.
Interpreting PPID 1 as systemd unit is wrong,
especially when embedded etcd runs under Docker
container. For such case, every single log write
will error and fall back to stderr, which is
inefficient.
Instead, add "systemd/journal" log output option
and returns error if systemd/journal socket cannot
be found.
"--logger=zap --log-outputs=default" will only error
for v3.4, since zap logger is still experimental.
v3.5 deprecates capnslog and changes "--log-outputs"
default value to "--log-outputs=stderr".
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-05-16 14:47:43 -07:00