Runtime logging. (#3821)

* Implement Printable for tuples.

* Add debugging function.

* Add debug 1.

* Implement  for everything.

* RuntimeDebug derive.

* Introduce RuntimeDebug.

* Add some dummy logging.

* Replace RuntimeDebug with Debug.

* Revert "Replace RuntimeDebug with Debug."

This reverts commit bc47070a8cb30241b2b590b2fa29fd195088162f.

* Working on Debug for all.

* Fix bounds.

* Add debug utils.

* Implement runtime logging.

* Add some docs and clean up.

* Clean up derives.

* Fix custom derive impl.

* Bump runtime.

* Fix long lines.

* Fix doc test.

* Use CARGO_CFG_STD.

* Revert "Use CARGO_CFG_STD."

This reverts commit ea429566de18ed0fa052571b359eb9826a64a9f4.

* Use parse_macro_input

* Update lockfile.

* Apply review suggestions.

* Remove stray re-export.

* Add no-std impl.

* Update lockfile.
This commit is contained in:
Tomasz Drwięga
2019-10-22 14:13:44 +02:00
committed by Bastian Köcher
parent 934d7aac1c
commit 20a3989785
86 changed files with 1266 additions and 469 deletions
+11 -12
View File
@@ -148,7 +148,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use rstd::prelude::*;
use rstd::{cmp, result, mem};
use rstd::{cmp, result, mem, fmt::Debug};
use codec::{Codec, Encode, Decode};
use support::{
StorageValue, Parameter, decl_event, decl_storage, decl_module,
@@ -160,8 +160,9 @@ use support::{
dispatch::Result,
};
use sr_primitives::{
RuntimeDebug,
traits::{
Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug,
Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDeserialize,
Saturating, Bounded,
},
weights::SimpleDispatchInfo,
@@ -176,7 +177,7 @@ pub use self::imbalances::{PositiveImbalance, NegativeImbalance};
pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
/// The balance of an account.
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
MaybeSerializeDebug + From<Self::BlockNumber>;
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
/// A function that is invoked when the free-balance has fallen below the existential deposit and
/// has been reduced to zero.
@@ -200,7 +201,7 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
/// The balance of an account.
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
MaybeSerializeDebug + From<Self::BlockNumber>;
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
/// A function that is invoked when the free-balance has fallen below the existential deposit and
/// has been reduced to zero.
@@ -255,8 +256,7 @@ decl_event!(
);
/// Struct to encode the vesting schedule of an individual account.
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct VestingSchedule<Balance, BlockNumber> {
/// Locked amount at genesis.
pub locked: Balance,
@@ -283,8 +283,7 @@ impl<Balance: SimpleArithmetic + Copy, BlockNumber: SimpleArithmetic + Copy> Ves
}
}
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct BalanceLock<Balance, BlockNumber> {
pub id: LockIdentifier,
pub amount: Balance,
@@ -772,7 +771,7 @@ impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> {
impl<T: Trait<I>, I: Instance> Currency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDebug
T::Balance: MaybeSerializeDeserialize + Debug
{
type Balance = T::Balance;
type PositiveImbalance = PositiveImbalance<T, I>;
@@ -1009,7 +1008,7 @@ where
impl<T: Trait<I>, I: Instance> ReservableCurrency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDebug
T::Balance: MaybeSerializeDeserialize + Debug
{
fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool {
Self::free_balance(who)
@@ -1072,7 +1071,7 @@ where
impl<T: Trait<I>, I: Instance> LockableCurrency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDebug
T::Balance: MaybeSerializeDeserialize + Debug
{
type Moment = T::BlockNumber;
@@ -1146,7 +1145,7 @@ where
impl<T: Trait<I>, I: Instance> IsDeadAccount<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDebug
T::Balance: MaybeSerializeDeserialize + Debug
{
fn is_dead_account(who: &T::AccountId) -> bool {
Self::total_balance(who).is_zero()