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

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
release-3.4
Gyuho Lee 2018-03-07 10:45:29 -08:00
parent 89292affaa
commit 82ee796aa4
8 changed files with 16 additions and 21 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package logger
package logutil
import (
"log"

View File

@ -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

View File

@ -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

View File

@ -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())

View File

@ -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 (

View File

@ -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

View File

@ -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"

View File

@ -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})