Move from seelog to glog

This commit is contained in:
Łukasz Kurowski 2015-01-31 16:49:21 +01:00
parent 35fd6796b1
commit 323dfbc818
6 changed files with 20 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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