Skip to content

Commit

Permalink
embed: do not import journald dependencies on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Apr 25, 2018
1 parent 9cd9ae2 commit 154e2ac
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func (cfg *Config) setupLogging() error {
}
} else {
// use stderr as fallback
syncer := zapcore.AddSync(logutil.NewJournaldWriter(os.Stderr))
syncer := getZapWriteSyncer()
lvl := zap.NewAtomicLevelAt(zap.InfoLevel)
if cfg.Debug {
lvl = zap.NewAtomicLevelAt(zap.DebugLevel)
Expand Down
28 changes: 28 additions & 0 deletions embed/journald_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2018 The etcd Authors
//
// 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.

// +build !windows

package embed

import (
"os"

"github.com/coreos/etcd/pkg/logutil"
"go.uber.org/zap/zapcore"
)

func getZapWriteSyncer() zapcore.WriteSyncer {
return zapcore.AddSync(logutil.NewJournaldWriter(os.Stderr))
}
27 changes: 27 additions & 0 deletions embed/journald_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 The etcd Authors
//
// 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.

// +build windows

package embed

import (
"os"

"go.uber.org/zap/zapcore"
)

func getZapWriteSyncer() zapcore.WriteSyncer {
return zapcore.AddSync(os.Stderr)
}

0 comments on commit 154e2ac

Please sign in to comment.