diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 22:49:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-23 22:49:05 +0800 |
commit | 357732a8404c9fe4d02f041d20a0d05381a3e6d1 (patch) | |
tree | edaf8a63eb7f7434cd9b9cbd764b3c4c3d76191e /whisper/whisperv5/api.go | |
parent | 29fac7de448c85049a97cbec3dc0819122bd2cb0 (diff) | |
parent | f89dd627760b43bd405cb3db1e5efdb100835db5 (diff) | |
download | dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.gz dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.bz2 dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.lz dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.xz dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.zst dexon-357732a8404c9fe4d02f041d20a0d05381a3e6d1.zip |
Merge pull request #3696 from karalabe/contextual-logger
Contextual logger
Diffstat (limited to 'whisper/whisperv5/api.go')
-rw-r--r-- | whisper/whisperv5/api.go | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/whisper/whisperv5/api.go b/whisper/whisperv5/api.go index 4d33d2321..d34213e05 100644 --- a/whisper/whisperv5/api.go +++ b/whisper/whisperv5/api.go @@ -25,8 +25,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" ) var whisperOffLineErr = errors.New("whisper is offline") @@ -170,25 +169,25 @@ func (api *PublicWhisperAPI) NewFilter(args WhisperFilterArgs) (string, error) { if len(args.Topics) == 0 && len(args.KeyName) != 0 { info := "NewFilter: at least one topic must be specified" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } if len(args.KeyName) != 0 && len(filter.KeySym) == 0 { info := "NewFilter: key was not found by name: " + args.KeyName - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } if len(args.To) == 0 && len(filter.KeySym) == 0 { info := "NewFilter: filter must contain either symmetric or asymmetric key" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } if len(args.To) != 0 && len(filter.KeySym) != 0 { info := "NewFilter: filter must not contain both symmetric and asymmetric key" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } @@ -196,13 +195,13 @@ func (api *PublicWhisperAPI) NewFilter(args WhisperFilterArgs) (string, error) { dst := crypto.ToECDSAPub(common.FromHex(args.To)) if !ValidatePublicKey(dst) { info := "NewFilter: Invalid 'To' address" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } filter.KeyAsym = api.whisper.GetIdentity(string(args.To)) if filter.KeyAsym == nil { info := "NewFilter: non-existent identity provided" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } } @@ -210,7 +209,7 @@ func (api *PublicWhisperAPI) NewFilter(args WhisperFilterArgs) (string, error) { if len(args.From) > 0 { if !ValidatePublicKey(filter.Src) { info := "NewFilter: Invalid 'From' address" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return "", errors.New(info) } } @@ -269,13 +268,13 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { pub := crypto.ToECDSAPub(common.FromHex(args.From)) if !ValidatePublicKey(pub) { info := "Post: Invalid 'From' address" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } params.Src = api.whisper.GetIdentity(string(args.From)) if params.Src == nil { info := "Post: non-existent identity provided" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } } @@ -283,7 +282,7 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { filter := api.whisper.GetFilter(args.FilterID) if filter == nil && len(args.FilterID) > 0 { info := fmt.Sprintf("Post: wrong filter id %s", args.FilterID) - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } @@ -299,7 +298,7 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { sz := len(filter.Topics) if sz < 1 { info := fmt.Sprintf("Post: no topics in filter # %s", args.FilterID) - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } else if sz == 1 { params.Topic = filter.Topics[0] @@ -314,26 +313,26 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { // validate if len(args.KeyName) != 0 && len(params.KeySym) == 0 { info := "Post: key was not found by name: " + args.KeyName - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } if len(args.To) == 0 && len(params.KeySym) == 0 { info := "Post: message must be encrypted either symmetrically or asymmetrically" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } if len(args.To) != 0 && len(params.KeySym) != 0 { info := "Post: ambigous encryption method requested" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } if len(args.To) > 0 { if !ValidatePublicKey(params.Dst) { info := "Post: Invalid 'To' address" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } } @@ -342,17 +341,17 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { message := NewSentMessage(¶ms) envelope, err := message.Wrap(¶ms) if err != nil { - glog.V(logger.Error).Infof(err.Error()) + log.Error(fmt.Sprintf(err.Error())) return err } if len(envelope.Data) > MaxMessageLength { info := "Post: message is too big" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } if (envelope.Topic == TopicType{} && envelope.IsSymmetric()) { info := "Post: topic is missing for symmetric encryption" - glog.V(logger.Error).Infof(info) + log.Error(fmt.Sprintf(info)) return errors.New(info) } |