1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 11:52:21 +08:00

Replace Critical{,f} with Error{,f}

Except when there is an explicit os.Exit(1) after the Critical line,
then replace with Fatal{,f}.
golang's log and logrus already call os.Exit(1) by default with Fatal.

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
rht
2015-06-12 04:36:25 +07:00
parent 6bc9086b4c
commit 78b6cc5f2d
9 changed files with 12 additions and 15 deletions

View File

@ -465,7 +465,7 @@ func startProfiling() (func(), error) {
for _ = range time.NewTicker(time.Second * 30).C {
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
log.Error(err)
}
}
}()

View File

@ -45,7 +45,7 @@ output of a running daemon.
// TODO use a different keyword for 'all' because all can theoretically
// clash with a subsystem name
cmds.StringArg("subsystem", true, false, fmt.Sprintf("the subsystem logging identifier. Use '%s' for all subsystems.", logAllKeyword)),
cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, fatal"),
},
Run: func(req cmds.Request, res cmds.Response) {

View File

@ -462,10 +462,10 @@ func (dir *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDi
return err
}
case *File:
log.Critical("Cannot move node into a file!")
log.Error("Cannot move node into a file!")
return fuse.EPERM
default:
log.Critical("Unknown node type for rename target dir!")
log.Error("Unknown node type for rename target dir!")
return errors.New("Unknown fs node type!")
}
return nil

View File

@ -285,7 +285,7 @@ func (np *Republisher) Run(ctx context.Context) {
log.Info("Publishing Changes!")
err := np.root.Publish(ctx)
if err != nil {
log.Critical("republishRoot error: %s", err)
log.Error("republishRoot error: %s", err)
}
case <-ctx.Done():

View File

@ -24,7 +24,7 @@ type TestBogusPrivateKey []byte
type TestBogusPublicKey []byte
func (pk TestBogusPublicKey) Verify(data, sig []byte) (bool, error) {
log.Criticalf("TestBogusPublicKey.Verify -- this better be a test!")
log.Errorf("TestBogusPublicKey.Verify -- this better be a test!")
return bytes.Equal(data, reverse(sig)), nil
}
@ -33,7 +33,7 @@ func (pk TestBogusPublicKey) Bytes() ([]byte, error) {
}
func (pk TestBogusPublicKey) Encrypt(b []byte) ([]byte, error) {
log.Criticalf("TestBogusPublicKey.Encrypt -- this better be a test!")
log.Errorf("TestBogusPublicKey.Encrypt -- this better be a test!")
return reverse(b), nil
}
@ -51,7 +51,7 @@ func (sk TestBogusPrivateKey) GenSecret() []byte {
}
func (sk TestBogusPrivateKey) Sign(message []byte) ([]byte, error) {
log.Criticalf("TestBogusPrivateKey.Sign -- this better be a test!")
log.Errorf("TestBogusPrivateKey.Sign -- this better be a test!")
return reverse(message), nil
}
@ -60,7 +60,7 @@ func (sk TestBogusPrivateKey) GetPublic() ic.PubKey {
}
func (sk TestBogusPrivateKey) Decrypt(b []byte) ([]byte, error) {
log.Criticalf("TestBogusPrivateKey.Decrypt -- this better be a test!")
log.Errorf("TestBogusPrivateKey.Decrypt -- this better be a test!")
return reverse(b), nil
}

View File

@ -89,7 +89,7 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
for _, pi := range closerinfos {
log.Debugf("handleGetValue returning closer peer: '%s'", pi.ID)
if len(pi.Addrs) < 1 {
log.Criticalf(`no addresses on peer being sent!
log.Errorf(`no addresses on peer being sent!
[local:%s]
[sending:%s]
[remote:%s]`, dht.self, pi.ID, p)

View File

@ -50,7 +50,7 @@ func (px *standard) Bootstrap(ctx context.Context) error {
cxns = append(cxns, info)
}
if len(cxns) == 0 {
log.Critical("unable to bootstrap to any supernode routers")
log.Error("unable to bootstrap to any supernode routers")
} else {
log.Infof("bootstrapped to %d supernode routers: %s", len(cxns), cxns)
}

View File

@ -11,8 +11,6 @@ import (
// StandardLogger provides API compatibility with standard printf loggers
// eg. go-logging
type StandardLogger interface {
Critical(args ...interface{})
Criticalf(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Error(args ...interface{})

View File

@ -90,8 +90,7 @@ func init() {
var err error
currentVersion, err = parseVersion()
if err != nil {
log.Criticalf("invalid version number in code (must be semver): %q", Version)
os.Exit(1)
log.Fatalf("invalid version number in code (must be semver): %q", Version)
}
log.Infof("go-ipfs Version: %s", currentVersion)
}