Fix logging

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
Hector Sanjuan 2017-03-14 17:32:00 +01:00
parent b4dd8dd9c6
commit 03a931b8df
5 changed files with 21 additions and 15 deletions

View File

@ -142,7 +142,6 @@ func NewRaft(peers []peer.ID, host host.Host, dataFolder string, fsm hashiraft.F
func (r *Raft) WaitForLeader(ctx context.Context) error {
// Using Raft observers panics on non-64 architectures.
// This is a work around
logger.Info("waiting for leader")
if sixtyfour {
return r.waitForLeader(ctx)
}

View File

@ -280,28 +280,30 @@ func run(c *cli.Context) error {
}
}
func setupLogging(lvl string) {
ipfscluster.SetFacilityLogLevel("service", lvl)
ipfscluster.SetFacilityLogLevel("cluster", lvl)
//ipfscluster.SetFacilityLogLevel("raft", lvl)
}
func setupDebug() {
l := "DEBUG"
var facilities = []string{
"service",
"cluster",
"restapi",
"ipfshttp",
"monitor",
"consensus",
"raft",
"p2p-gorpc",
"pintracker",
}
func setupLogging(lvl string) {
for _, f := range facilities {
ipfscluster.SetFacilityLogLevel(f, lvl)
}
}
func setupDebug() {
l := "DEBUG"
for _, f := range facilities {
ipfscluster.SetFacilityLogLevel(f, l)
}
ipfscluster.SetFacilityLogLevel("p2p-gorpc", l)
ipfscluster.SetFacilityLogLevel("raft", l)
//SetFacilityLogLevel("swarm2", l)
//SetFacilityLogLevel("libp2p-raft", l)
}

View File

@ -518,7 +518,7 @@ func (ipfs *Connector) get(path string) ([]byte, error) {
msg = fmt.Sprintf("IPFS-get '%s' unsuccessful: %d: %s",
path, resp.StatusCode, body)
}
logger.Warning(msg)
return body, errors.New(msg)
}
return body, nil

View File

@ -11,6 +11,7 @@ var facilities = []string{
"monitor",
"consensus",
"raft",
"pintracker",
}
// SetFacilityLogLevel sets the log level for a given module

View File

@ -205,6 +205,7 @@ func (mpt *MapPinTracker) isRemote(c api.Pin) bool {
}
func (mpt *MapPinTracker) pin(c api.Pin) error {
logger.Debugf("issuing pin call for %s", c.Cid)
mpt.set(c.Cid, api.TrackerStatusPinning)
err := mpt.rpcClient.Call("",
"Cluster",
@ -222,6 +223,7 @@ func (mpt *MapPinTracker) pin(c api.Pin) error {
}
func (mpt *MapPinTracker) unpin(c api.Pin) error {
logger.Debugf("issuing unpin call for %s", c.Cid)
err := mpt.rpcClient.Call("",
"Cluster",
"IPFSUnpin",
@ -239,6 +241,7 @@ func (mpt *MapPinTracker) unpin(c api.Pin) error {
// Track tells the MapPinTracker to start managing a Cid,
// possibly trigerring Pin operations on the IPFS daemon.
func (mpt *MapPinTracker) Track(c api.Pin) error {
logger.Debugf("tracking %s", c.Cid)
if mpt.isRemote(c) {
if mpt.get(c.Cid).Status == api.TrackerStatusPinned {
mpt.unpin(c)
@ -262,6 +265,7 @@ func (mpt *MapPinTracker) Track(c api.Pin) error {
// Untrack tells the MapPinTracker to stop managing a Cid.
// If the Cid is pinned locally, it will be unpinned.
func (mpt *MapPinTracker) Untrack(c *cid.Cid) error {
logger.Debugf("untracking %s", c)
mpt.set(c, api.TrackerStatusUnpinning)
select {
case mpt.unpinCh <- api.PinCid(c):