From 323dfbc818387e5b77f749ccca774cc38c869b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kurowski?= Date: Sat, 31 Jan 2015 16:49:21 +0100 Subject: [PATCH] Move from seelog to glog --- README.md | 8 +++----- server/rpc_server.go | 10 +++++----- server/server.go | 13 +++++++------ server/server_context.go | 4 ++-- template/handler/example.go | 4 ++-- template/main.go | 4 +--- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 4bb9d7ed..c4aa3475 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ import ( "github.com/asim/go-micro/server" example "github.com/asim/go-micro/template/proto/example" - log "github.com/cihub/seelog" + log "github.com/golang/glog" ) type Example struct{} func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error { - log.Debug("Received Example.Call request") + log.Info("Received Example.Call request") rsp.Msg = proto.String(server.Id + ": Hello " + req.GetName()) @@ -87,10 +87,9 @@ func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.R package main import ( - "log" - "github.com/asim/go-micro/server" "github.com/asim/go-micro/template/handler" + log "github.com/golang/glog" ) func main() { @@ -110,7 +109,6 @@ func main() { if err := server.Run(); err != nil { log.Fatal(err) } - } ``` diff --git a/server/rpc_server.go b/server/rpc_server.go index c2f87491..4a72238b 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -11,7 +11,7 @@ import ( "sync" "github.com/asim/go-micro/errors" - log "github.com/cihub/seelog" + log "github.com/golang/glog" rpc "github.com/youtube/vitess/go/rpcplus" js "github.com/youtube/vitess/go/rpcplus/jsonrpc" pb "github.com/youtube/vitess/go/rpcplus/pbrpc" @@ -32,8 +32,8 @@ var ( func executeRequestSafely(c *serverContext, r *http.Request) { defer func() { if x := recover(); x != nil { - log.Criticalf("Panicked on request: %v", r) - log.Criticalf("%v: %v", x, string(debug.Stack())) + log.Warningf("Panicked on request: %v", r) + log.Warningf("%v: %v", x, string(debug.Stack())) err := errors.InternalServerError("go.micro.server", "Unexpected error") c.WriteHeader(500) c.Write([]byte(err.Error())) @@ -153,7 +153,7 @@ func (s *RpcServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { } func (s *RpcServer) Init() error { - log.Debugf("Rpc handler %s", RpcPath) + log.Infof("Rpc handler %s", RpcPath) http.Handle(RpcPath, s) return nil } @@ -184,7 +184,7 @@ func (s *RpcServer) Start() error { return err } - log.Debugf("Listening on %s", l.Addr().String()) + log.Infof("Listening on %s", l.Addr().String()) s.mtx.Lock() s.address = l.Addr().String() diff --git a/server/server.go b/server/server.go index 92f22e77..5e5b3f7f 100644 --- a/server/server.go +++ b/server/server.go @@ -11,7 +11,7 @@ import ( "code.google.com/p/go-uuid/uuid" "github.com/asim/go-micro/registry" "github.com/asim/go-micro/store" - log "github.com/cihub/seelog" + log "github.com/golang/glog" ) type Server interface { @@ -39,6 +39,7 @@ func init() { } func Init() error { + defer log.Flush() flag.Parse() switch flagRegistry { @@ -88,25 +89,25 @@ func Run() error { node := registry.NewNode(Id, host, port) service := registry.NewService(Name, node) - log.Debugf("Registering %s", node.Id()) + log.Infof("Registering %s", node.Id()) registry.Register(service) ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) - log.Debugf("Received signal %s", <-ch) + log.Infof("Received signal %s", <-ch) - log.Debugf("Deregistering %s", node.Id()) + log.Infof("Deregistering %s", node.Id()) registry.Deregister(service) return Stop() } func Start() error { - log.Debugf("Starting server %s id %s", Name, Id) + log.Infof("Starting server %s id %s", Name, Id) return DefaultServer.Start() } func Stop() error { - log.Debugf("Stopping server") + log.Infof("Stopping server") return DefaultServer.Stop() } diff --git a/server/server_context.go b/server/server_context.go index 82955682..f986266b 100644 --- a/server/server_context.go +++ b/server/server_context.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/asim/go-micro/client" - log "github.com/cihub/seelog" + log "github.com/golang/glog" ) var ctxs = struct { @@ -109,7 +109,7 @@ func (c *serverContext) Write(b []byte) (int, error) { func (c *serverContext) WriteHeader(code int) { if c.outCode != 0 { - log.Errorf("WriteHeader called multiple times on request.") + log.Error("WriteHeader called multiple times on request.") return } c.outCode = code diff --git a/template/handler/example.go b/template/handler/example.go index aeb47a1c..678e94e9 100644 --- a/template/handler/example.go +++ b/template/handler/example.go @@ -6,13 +6,13 @@ import ( "github.com/asim/go-micro/server" example "github.com/asim/go-micro/template/proto/example" - log "github.com/cihub/seelog" + log "github.com/golang/glog" ) type Example struct{} func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error { - log.Debug("Received Example.Call request") + log.Info("Received Example.Call request") rsp.Msg = proto.String(server.Id + ": Hello " + req.GetName()) diff --git a/template/main.go b/template/main.go index f946c448..055e8d4f 100644 --- a/template/main.go +++ b/template/main.go @@ -1,10 +1,9 @@ package main import ( - "log" - "github.com/asim/go-micro/server" "github.com/asim/go-micro/template/handler" + log "github.com/golang/glog" ) func main() { @@ -24,5 +23,4 @@ func main() { if err := server.Run(); err != nil { log.Fatal(err) } - }