Explorar o código

pkg/logutil: move "pkg/logger" to "logutil"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee %!s(int64=7) %!d(string=hai) anos
pai
achega
82ee796aa4

+ 1 - 1
pkg/logger/discard.go → 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"

+ 2 - 2
pkg/logger/doc.go → 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

+ 3 - 3
pkg/logger/logger.go → 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

+ 4 - 4
pkg/logger/logger_test.go → 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())

+ 0 - 1
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 (

+ 1 - 5
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

+ 1 - 1
pkg/logger/package_logger.go → 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"

+ 4 - 4
pkg/logger/package_logger_test.go → 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})