mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-10 21:52:01 +02:00
remove use of glog
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/golang/glog"
|
||||
"log"
|
||||
|
||||
"github.com/micro/go-micro/cmd"
|
||||
"github.com/micro/go-micro/examples/server/subscriber"
|
||||
"github.com/micro/go-micro/server"
|
||||
@@ -13,16 +14,16 @@ import (
|
||||
type Example struct{}
|
||||
|
||||
func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error {
|
||||
log.Info("Received Example.Call request")
|
||||
log.Print("Received Example.Call request")
|
||||
rsp.Msg = server.DefaultOptions().Id + ": Hello " + req.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Example) Stream(ctx context.Context, req *example.StreamingRequest, stream example.Example_StreamStream) error {
|
||||
log.Infof("Received Example.Stream request with count: %d", req.Count)
|
||||
log.Printf("Received Example.Stream request with count: %d", req.Count)
|
||||
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
log.Infof("Responding: %d", i)
|
||||
log.Printf("Responding: %d", i)
|
||||
if err := stream.Send(&example.StreamingResponse{
|
||||
Count: int64(i),
|
||||
}); err != nil {
|
||||
@@ -39,7 +40,7 @@ func (e *Example) PingPong(ctx context.Context, stream example.Example_PingPongS
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Got ping %v", req.Stroke)
|
||||
log.Printf("Got ping %v", req.Stroke)
|
||||
if err := stream.Send(&example.Pong{Stroke: req.Stroke}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
log "github.com/golang/glog"
|
||||
"log"
|
||||
|
||||
example "github.com/micro/go-micro/examples/server/proto/example"
|
||||
"github.com/micro/go-micro/metadata"
|
||||
"github.com/micro/go-micro/server"
|
||||
@@ -13,25 +14,25 @@ type Example struct{}
|
||||
|
||||
func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error {
|
||||
md, _ := metadata.FromContext(ctx)
|
||||
log.Infof("Received Example.Call request with metadata: %v", md)
|
||||
log.Printf("Received Example.Call request with metadata: %v", md)
|
||||
rsp.Msg = server.DefaultOptions().Id + ": Hello " + req.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Example) Stream(ctx context.Context, stream server.Streamer) error {
|
||||
log.Info("Executing streaming handler")
|
||||
log.Print("Executing streaming handler")
|
||||
req := &example.StreamingRequest{}
|
||||
|
||||
// We just want to receive 1 request and then process here
|
||||
if err := stream.Recv(req); err != nil {
|
||||
log.Errorf("Error receiving streaming request: %v", err)
|
||||
log.Printf("Error receiving streaming request: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("Received Example.Stream request with count: %d", req.Count)
|
||||
log.Printf("Received Example.Stream request with count: %d", req.Count)
|
||||
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
log.Infof("Responding: %d", i)
|
||||
log.Printf("Responding: %d", i)
|
||||
|
||||
if err := stream.Send(&example.StreamingResponse{
|
||||
Count: int64(i),
|
||||
@@ -49,7 +50,7 @@ func (e *Example) PingPong(ctx context.Context, stream server.Streamer) error {
|
||||
if err := stream.Recv(req); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Got ping %v", req.Stroke)
|
||||
log.Printf("Got ping %v", req.Stroke)
|
||||
if err := stream.Send(&example.Pong{Stroke: req.Stroke}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/golang/glog"
|
||||
"log"
|
||||
|
||||
"github.com/micro/go-micro/cmd"
|
||||
"github.com/micro/go-micro/examples/server/handler"
|
||||
"github.com/micro/go-micro/examples/server/subscriber"
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package subscriber
|
||||
|
||||
import (
|
||||
log "github.com/golang/glog"
|
||||
"log"
|
||||
|
||||
example "github.com/micro/go-micro/examples/server/proto/example"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
@@ -9,11 +10,11 @@ import (
|
||||
type Example struct{}
|
||||
|
||||
func (e *Example) Handle(ctx context.Context, msg *example.Message) error {
|
||||
log.Info("Handler Received message: ", msg.Say)
|
||||
log.Print("Handler Received message: ", msg.Say)
|
||||
return nil
|
||||
}
|
||||
|
||||
func Handler(ctx context.Context, msg *example.Message) error {
|
||||
log.Info("Function Received message: ", msg.Say)
|
||||
log.Print("Function Received message: ", msg.Say)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user