diff --git a/pkg/logger/discard.go b/pkg/logutil/discard_logger.go similarity index 99% rename from pkg/logger/discard.go rename to pkg/logutil/discard_logger.go index 0ac32462e..81b0a9d03 100644 --- a/pkg/logger/discard.go +++ b/pkg/logutil/discard_logger.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package logger +package logutil import ( "log" diff --git a/pkg/logger/doc.go b/pkg/logutil/doc.go similarity index 88% rename from pkg/logger/doc.go rename to pkg/logutil/doc.go index c32ffae4c..e919f2499 100644 --- a/pkg/logger/doc.go +++ b/pkg/logutil/doc.go @@ -12,5 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package logger implements various logging utilities. -package logger +// Package logutil includes utilities to facilitate logging. +package logutil diff --git a/pkg/logger/logger.go b/pkg/logutil/logger.go similarity index 93% rename from pkg/logger/logger.go rename to pkg/logutil/logger.go index 1256cec64..cd1de5f7f 100644 --- a/pkg/logger/logger.go +++ b/pkg/logutil/logger.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package logger +package logutil import "google.golang.org/grpc/grpclog" @@ -28,7 +28,7 @@ type Logger interface { // assert that "defaultLogger" satisfy "Logger" interface var _ Logger = &defaultLogger{} -// New wraps "grpclog.LoggerV2" that implements "Logger" interface. +// NewLogger wraps "grpclog.LoggerV2" that implements "Logger" interface. // // For example: // @@ -36,7 +36,7 @@ var _ Logger = &defaultLogger{} // g := grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4) // defaultLogger = New(g) // -func New(g grpclog.LoggerV2) Logger { return &defaultLogger{g: g} } +func NewLogger(g grpclog.LoggerV2) Logger { return &defaultLogger{g: g} } type defaultLogger struct { g grpclog.LoggerV2 diff --git a/pkg/logger/logger_test.go b/pkg/logutil/logger_test.go similarity index 85% rename from pkg/logger/logger_test.go rename to pkg/logutil/logger_test.go index b50eeb2a8..1f2ef9b68 100644 --- a/pkg/logger/logger_test.go +++ b/pkg/logutil/logger_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package logger_test +package logutil_test import ( "bytes" @@ -20,7 +20,7 @@ import ( "strings" "testing" - "github.com/coreos/etcd/pkg/logger" + "github.com/coreos/etcd/pkg/logutil" "google.golang.org/grpc/grpclog" ) @@ -28,7 +28,7 @@ import ( func TestLogger(t *testing.T) { buf := new(bytes.Buffer) - l := logger.New(grpclog.NewLoggerV2WithVerbosity(buf, buf, buf, 10)) + l := logutil.NewLogger(grpclog.NewLoggerV2WithVerbosity(buf, buf, buf, 10)) l.Infof("hello world!") if !strings.Contains(buf.String(), "hello world!") { t.Fatalf("expected 'hello world!', got %q", buf.String()) @@ -45,7 +45,7 @@ func TestLogger(t *testing.T) { } buf.Reset() - l = logger.New(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard)) + l = logutil.NewLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard)) l.Infof("ignore this") if len(buf.Bytes()) > 0 { t.Fatalf("unexpected logs %q", buf.String()) diff --git a/pkg/logutil/merge_logger.go b/pkg/logutil/merge_logger.go index cc750f4d3..866b6f7a8 100644 --- a/pkg/logutil/merge_logger.go +++ b/pkg/logutil/merge_logger.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package logutil includes utilities to facilitate logging. package logutil import ( diff --git a/pkg/logutil/merge_logger_test.go b/pkg/logutil/merge_logger_test.go index 99e422d9d..10d0e4372 100644 --- a/pkg/logutil/merge_logger_test.go +++ b/pkg/logutil/merge_logger_test.go @@ -23,16 +23,12 @@ import ( "github.com/coreos/pkg/capnslog" ) -var ( - testLogger = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/logutil") -) - func TestMergeLogger(t *testing.T) { var ( txt = "hello" repeatN = 6 duration = 2049843762 * time.Nanosecond - mg = NewMergeLogger(testLogger) + mg = NewMergeLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/logutil")) ) // overwrite this for testing defaultMergePeriod = time.Minute diff --git a/pkg/logger/package_logger.go b/pkg/logutil/package_logger.go similarity index 99% rename from pkg/logger/package_logger.go rename to pkg/logutil/package_logger.go index 576f31d2f..378bee0e3 100644 --- a/pkg/logger/package_logger.go +++ b/pkg/logutil/package_logger.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package logger +package logutil import ( "github.com/coreos/pkg/capnslog" diff --git a/pkg/logger/package_logger_test.go b/pkg/logutil/package_logger_test.go similarity index 92% rename from pkg/logger/package_logger_test.go rename to pkg/logutil/package_logger_test.go index 8205ec9f5..b6ab0052b 100644 --- a/pkg/logger/package_logger_test.go +++ b/pkg/logutil/package_logger_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package logger_test +package logutil_test import ( "bytes" @@ -20,16 +20,16 @@ import ( "strings" "testing" - "github.com/coreos/pkg/capnslog" + "github.com/coreos/etcd/pkg/logutil" - "github.com/coreos/etcd/pkg/logger" + "github.com/coreos/pkg/capnslog" ) func TestPackageLogger(t *testing.T) { buf := new(bytes.Buffer) capnslog.SetFormatter(capnslog.NewDefaultFormatter(buf)) - l := logger.NewPackageLogger("github.com/coreos/etcd", "logger") + l := logutil.NewPackageLogger("github.com/coreos/etcd", "logger") r := capnslog.MustRepoLogger("github.com/coreos/etcd") r.SetLogLevel(map[string]capnslog.LogLevel{"logger": capnslog.INFO})