提交 094106ad 编写于 作者: H Helin Wang

use logrus for logging

上级 e730bc59
......@@ -2,9 +2,10 @@ package connection
import (
"errors"
"log"
"net/rpc"
"sync"
log "github.com/sirupsen/logrus"
)
// TODO(helin): add TCP re-connect logic
......@@ -65,7 +66,7 @@ func (c *Conn) Connect(addr string) error {
} else {
err := client.Close()
if err != nil {
log.Println(err)
log.Errorln(err)
}
return errors.New("client already set from a concurrent goroutine")
......
......@@ -13,11 +13,11 @@ typedef int paddle_master_client;
import "C"
import (
"log"
"sync"
"unsafe"
"github.com/PaddlePaddle/Paddle/go/master"
log "github.com/sirupsen/logrus"
)
var nullPtr = unsafe.Pointer(uintptr(0))
......@@ -77,7 +77,7 @@ func paddle_set_dataset(client C.paddle_master_client, path **C.char, size C.int
}
err := c.SetDataset(paths)
if err != nil {
log.Println(err)
log.Errorln(err)
return C.PADDLE_MASTER_ERROR
}
......
package master
import (
"log"
"os"
"time"
"github.com/PaddlePaddle/Paddle/go/connection"
"github.com/PaddlePaddle/recordio"
log "github.com/sirupsen/logrus"
)
// Addresser provide the address of the master server.
......@@ -36,14 +36,14 @@ func (c *Client) getRecords() {
if err != nil {
// TODO(helin): wait before move on with next
// getTask call.
log.Println(err)
log.Errorln(err)
continue
}
for _, chunk := range t.Chunks {
f, err := os.Open(chunk.Path)
if err != nil {
log.Println(err)
log.Errorln(err)
continue
}
......@@ -53,12 +53,12 @@ func (c *Client) getRecords() {
}
if s.Err() != nil {
log.Println(err, chunk.Path)
log.Errorln(err, chunk.Path)
}
err = f.Close()
if err != nil {
log.Println(err)
log.Errorln(err)
}
}
......@@ -79,12 +79,12 @@ func (c *Client) monitorMaster(addr Addresser) {
if curMaster == "" {
err := c.conn.Close()
if err != nil {
log.Println(err)
log.Errorln(err)
}
} else {
err := c.conn.Connect(curMaster)
if err != nil {
log.Println(err)
log.Errorln(err)
// connect to addr failed, set
// to last known addr in order
......
......@@ -25,12 +25,12 @@ typedef int paddle_pserver_client;
import "C"
import (
"log"
"strings"
"sync"
"unsafe"
"github.com/PaddlePaddle/Paddle/go/pserver"
log "github.com/sirupsen/logrus"
)
var nullPtr = unsafe.Pointer(uintptr(0))
......@@ -133,10 +133,10 @@ func paddle_init_param(client C.paddle_pserver_client, param C.paddle_parameter,
if err != nil {
if err.Error() == pserver.AlreadyInitialized {
log.Printf("parameter %s already initialized, treat paddle_init_param as sucessful.\n", name)
log.Warningf("parameter %s already initialized, treat paddle_init_param as sucessful.\n", name)
return C.PSERVER_OK
}
log.Println(err)
log.Errorln(err)
return C.PSERVER_ERROR
}
......@@ -149,11 +149,11 @@ func paddle_finish_init_params(client C.paddle_pserver_client) C.int {
err := c.FinishInitParams()
if err != nil {
if err.Error() == pserver.AlreadyInitialized {
log.Println("parameters already initialized, treat paddle_finish_init_params as sucessful.")
log.Warningln("parameters already initialized, treat paddle_finish_init_params as sucessful.")
return C.PSERVER_OK
}
log.Println(err)
log.Errorln(err)
return C.PSERVER_ERROR
}
......@@ -174,7 +174,7 @@ func paddle_send_grads(client C.paddle_pserver_client, grads **C.paddle_gradient
c := get(client)
err := c.SendGrads(gs)
if err != nil {
log.Println(err)
log.Errorln(err)
return C.PSERVER_ERROR
}
......@@ -191,7 +191,7 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
c := get(client)
ps, err := c.GetParams(ns)
if err != nil {
log.Println(err)
log.Errorln(err)
return C.PSERVER_ERROR
}
......@@ -200,7 +200,7 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
for i, p := range ps {
pn[i] = p.Name
}
log.Printf("pserver returned wrong number of parameters. Requested: %s, returned: %s.\n", strings.Join(pn, ", "), strings.Join(ns, ", "))
log.Errorf("pserver returned wrong number of parameters. Requested: %s, returned: %s.\n", strings.Join(pn, ", "), strings.Join(ns, ", "))
return C.PSERVER_ERROR
}
......@@ -210,7 +210,7 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
for i, p := range ps {
pn[i] = p.Name
}
log.Printf("pserver returned wrong parameters, or not in requested order. Requested: %s, returned: %s.\n", strings.Join(pn, ", "), strings.Join(ns, ", "))
log.Errorf("pserver returned wrong parameters, or not in requested order. Requested: %s, returned: %s.\n", strings.Join(pn, ", "), strings.Join(ns, ", "))
return C.PSERVER_ERROR
}
}
......@@ -220,13 +220,13 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
param := *(**C.paddle_parameter)(unsafe.Pointer((uintptr(unsafe.Pointer(dst)) + uintptr(i)*unsafe.Sizeof(*dst))))
if unsafe.Pointer(param) == nullPtr {
log.Println("must pre-allocate parameter.")
log.Errorln("must pre-allocate parameter.")
return C.PSERVER_ERROR
}
if unsafe.Pointer(param.content) != nullPtr {
if int(param.content_len) != len(p.Content) {
log.Printf("the pre-allocated content len does not match parameter content len. Pre-allocated len: %d, returned len: %d", param.content_len, len(p.Content))
log.Errorf("the pre-allocated content len does not match parameter content len. Pre-allocated len: %d, returned len: %d", param.content_len, len(p.Content))
return C.PSERVER_ERROR
}
}
......@@ -245,7 +245,7 @@ func paddle_save_model(client C.paddle_pserver_client, path *C.char) C.int {
c := get(client)
err := c.Save(p)
if err != nil {
log.Println(err)
log.Errorln(err)
return C.PSERVER_ERROR
}
......
......@@ -2,11 +2,11 @@ package pserver
import (
"hash/fnv"
"log"
"sort"
"time"
"github.com/PaddlePaddle/Paddle/go/connection"
log "github.com/sirupsen/logrus"
)
// TODO(helin): add RPC call retry logic
......@@ -64,7 +64,7 @@ func (c *Client) monitorPservers(l Lister, pserverNum int) {
if curServers[i].Addr == "" {
err := c.pservers[i].Close()
if err != nil {
log.Println(err)
log.Errorln(err)
}
continue
......@@ -72,7 +72,7 @@ func (c *Client) monitorPservers(l Lister, pserverNum int) {
err := c.pservers[i].Connect(curServers[i].Addr)
if err != nil {
log.Println(err)
log.Errorln(err)
// connect to addr failed, set
// to last known addr in order
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册