normalize logger
This commit is contained in:
parent
0b17e317d3
commit
e02bb54109
@ -20,6 +20,7 @@ import (
|
|||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -96,6 +97,11 @@ func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logger returns a module-specific logger.
|
||||||
|
func logger(ctx sdk.Context) log.Logger {
|
||||||
|
return ctx.Logger().With("module", types.ModuleName)
|
||||||
|
}
|
||||||
|
|
||||||
// GetRecordIndexKey Generates Bond ID -> Bond index key.
|
// GetRecordIndexKey Generates Bond ID -> Bond index key.
|
||||||
func GetRecordIndexKey(id string) []byte {
|
func GetRecordIndexKey(id string) []byte {
|
||||||
return append(PrefixCIDToRecordIndex, []byte(id)...)
|
return append(PrefixCIDToRecordIndex, []byte(id)...)
|
||||||
|
@ -611,7 +611,7 @@ func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) {
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
||||||
|
|
||||||
ctx.Logger().Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
|
logger(ctx).Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -672,7 +672,7 @@ func (k Keeper) AuthorityExpiryQueueIterator(ctx sdk.Context, endTime time.Time)
|
|||||||
|
|
||||||
// TryTakeAuthorityRent tries to take rent from the authority bond.
|
// TryTakeAuthorityRent tries to take rent from the authority bond.
|
||||||
func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority types.NameAuthority) {
|
func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority types.NameAuthority) {
|
||||||
ctx.Logger().Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
|
logger(ctx).Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
|
||||||
|
|
||||||
params := k.GetParams(ctx)
|
params := k.GetParams(ctx)
|
||||||
rent := params.AuthorityRent
|
rent := params.AuthorityRent
|
||||||
@ -684,7 +684,7 @@ func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority typ
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
||||||
|
|
||||||
ctx.Logger().Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
|
logger(ctx).Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority typ
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||||
|
|
||||||
ctx.Logger().Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
|
logger(ctx).Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListNameAuthorityRecords - get all name authority records.
|
// ListNameAuthorityRecords - get all name authority records.
|
||||||
|
@ -39,14 +39,14 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
name := k.GetAuctionToAuthorityMapping(ctx, auctionID)
|
name := k.GetAuctionToAuthorityMapping(ctx, auctionID)
|
||||||
if name == "" {
|
if name == "" {
|
||||||
// We don't know about this auction, ignore.
|
// We don't know about this auction, ignore.
|
||||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionID))
|
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
if !HasNameAuthority(store, name) {
|
if !HasNameAuthority(store, name) {
|
||||||
// We don't know about this authority, ignore.
|
// We don't know about this authority, ignore.
|
||||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionID))
|
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,12 +71,12 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
// Can be used to check if names are older than the authority itself (stale names).
|
// Can be used to check if names are older than the authority itself (stale names).
|
||||||
authority.Height = uint64(ctx.BlockHeight())
|
authority.Height = uint64(ctx.BlockHeight())
|
||||||
|
|
||||||
ctx.Logger().Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
|
logger(ctx).Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
|
||||||
} else {
|
} else {
|
||||||
// Mark as expired.
|
// Mark as expired.
|
||||||
authority.Status = types.AuthorityExpired
|
authority.Status = types.AuthorityExpired
|
||||||
|
|
||||||
ctx.Logger().Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
|
logger(ctx).Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
authority.AuctionId = ""
|
authority.AuctionId = ""
|
||||||
@ -85,7 +85,7 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
// Forget about this auction now, we no longer need it.
|
// Forget about this auction now, we no longer need it.
|
||||||
removeAuctionToAuthorityMapping(store, auctionID)
|
removeAuctionToAuthorityMapping(store, auctionID)
|
||||||
} else {
|
} else {
|
||||||
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
|
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user