mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
pkg/logutil: move "pkg/logger" to "logutil"
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
89292affaa
commit
82ee796aa4
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
package logutil
|
||||
|
||||
import (
|
||||
"log"
|
@ -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
|
@ -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
|
@ -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())
|
@ -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 (
|
||||
|
@ -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
|
||||
|
@ -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"
|
@ -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})
|
Loading…
x
Reference in New Issue
Block a user