Skip to content

Commit

Permalink
Merge pull request apache#1617 from cjphaha/feature/cjphaha_use_dubbo…
Browse files Browse the repository at this point in the history
…_logger

Ftr: change log to dubbo go logger
  • Loading branch information
cjphaha authored Nov 26, 2021
2 parents 938e7bf + 70deec6 commit a6aa373
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions protocol/dubbo3/internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package internal

import (
"context"
"log"
)

import (
"dubbo.apache.org/dubbo-go/v3/common"
log "dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
Expand All @@ -37,7 +37,7 @@ type Server struct {

// SayHello implements helloworld.GreeterServer
func (s *Server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, error) {
log.Printf("Received: %v", in.GetName())
log.Infof("Received: %v", in.GetName())
return &HelloReply{Message: "Hello " + in.GetName()}, nil
}

Expand Down
7 changes: 5 additions & 2 deletions protocol/grpc/internal/helloworld/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ package helloworld

import (
"context"
"log"
"net"
)

import (
"google.golang.org/grpc"
)

import (
log "dubbo.apache.org/dubbo-go/v3/common/logger"
)

// server is used to implement helloworld.GreeterServer.
type server struct {
*GreeterProviderBase
Expand All @@ -40,7 +43,7 @@ func NewService() *server {

// SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, error) {
log.Printf("Received: %v", in.GetName())
log.Infof("Received: %v", in.GetName())
return &HelloReply{Message: "Hello " + in.GetName()}, nil
}

Expand Down
10 changes: 5 additions & 5 deletions protocol/grpc/internal/routeguide/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package routeguide

import (
"io"
"log"
"math/rand"
"time"
)

import (
log "dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/config"
)

Expand All @@ -43,7 +43,7 @@ func PrintFeatures(stream RouteGuide_ListFeaturesClient) {
if err != nil {
log.Fatalf("Fait to receive a feature: %v", err)
}
log.Printf("Feature: name: %q, point:(%v, %v)", feature.GetName(),
log.Infof("Feature: name: %q, point:(%v, %v)", feature.GetName(),
feature.GetLocation().GetLatitude(), feature.GetLocation().GetLongitude())
}
}
Expand All @@ -57,7 +57,7 @@ func RunRecordRoute(stream RouteGuide_RecordRouteClient) {
for i := 0; i < pointCount; i++ {
points = append(points, randomPoint(r))
}
log.Printf("Traversing %d points.", len(points))
log.Infof("Traversing %d points.", len(points))
for _, point := range points {
if err := stream.Send(point); err != nil {
log.Fatalf("%v.Send(%v) = %v", stream, point, err)
Expand All @@ -67,7 +67,7 @@ func RunRecordRoute(stream RouteGuide_RecordRouteClient) {
if err != nil {
log.Fatalf("%v.CloseAndRecv() got error %v, want %v", stream, err, nil)
}
log.Printf("Route summary: %v", reply)
log.Infof("Route summary: %v", reply)
}

// runRouteChat receives a sequence of route notes, while sending notes for various locations.
Expand All @@ -92,7 +92,7 @@ func RunRouteChat(stream RouteGuide_RouteChatClient) {
if err != nil {
log.Fatalf("Failed to receive a note : %v", err)
}
log.Printf("Got message %s at point(%d, %d)", in.Message, in.Location.Latitude, in.Location.Longitude)
log.Infof("Got message %s at point(%d, %d)", in.Message, in.Location.Latitude, in.Location.Longitude)
}
}()
for _, note := range notes {
Expand Down
5 changes: 4 additions & 1 deletion protocol/grpc/internal/routeguide/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"math"
"net"
"sync"
Expand All @@ -35,6 +34,10 @@ import (
"google.golang.org/grpc"
)

import (
log "dubbo.apache.org/dubbo-go/v3/common/logger"
)

type routeGuideServer struct {
*RouteGuideProviderBase
savedFeatures []*Feature // read-only after initialized
Expand Down

0 comments on commit a6aa373

Please sign in to comment.