Skip to content

Commit ed81701

Browse files
author
Alain Brenzikofer
committed
migrate logging according to paritytech/substrate#8128
1 parent 642b455 commit ed81701

File tree

14 files changed

+468
-395
lines changed

14 files changed

+468
-395
lines changed

Cargo.lock

Lines changed: 414 additions & 346 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

balances/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ serde = { version = "1.0.101", optional = true }
99
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
1010
num-traits = { version = "0.2.8", default-features = false }
1111
impl-trait-for-tuples = "0.1.3"
12+
log = { version = "0.4.14", default-features = false }
1213

1314
[dependencies.encointer-primitives]
1415
default-features = false

balances/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ impl<T: Config> Module<T> {
182182
who: &T::AccountId,
183183
amount: BalanceType,
184184
) -> DispatchResult {
185-
debug::RuntimeLogger::init();
186185
let mut entry_who = Self::balance_entry_updated(community_id, who);
187186
let mut entry_tot = Self::total_issuance_entry_updated(community_id);
188187
ensure!(
@@ -193,7 +192,7 @@ impl<T: Config> Module<T> {
193192
entry_tot.principal += amount;
194193
<TotalIssuance<T>>::insert(community_id, entry_tot);
195194
<Balance<T>>::insert(community_id, who, entry_who);
196-
debug::debug!(target: LOG, "issue {:?} for {:?}", amount, who);
195+
log::debug!(target: LOG, "issue {:?} for {:?}", amount, who);
197196
Ok(())
198197
}
199198

bazaar/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors = ["encointer.org <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8+
log = { version = "0.4.14", default-features = false }
89

910
[dependencies.rstd]
1011
default-features = false

ceremonies/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors = ["encointer.org <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8+
log = { version = "0.4.14", default-features = false }
89

910
[dependencies.rstd]
1011
default-features = false

ceremonies/src/lib.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,17 @@ decl_module! {
112112

113113
#[weight = 10_000]
114114
pub fn grant_reputation(origin, cid: CommunityIdentifier, reputable: T::AccountId) -> DispatchResult {
115-
debug::RuntimeLogger::init();
115+
log::RuntimeLogger::init();
116116
let sender = ensure_signed(origin)?;
117117
ensure!(sender == <encointer_scheduler::Module<T>>::ceremony_master(), "only the CeremonyMaster can call this function");
118118
let cindex = <encointer_scheduler::Module<T>>::current_ceremony_index();
119119
<ParticipantReputation<T>>::insert(&(cid, cindex-1), reputable, Reputation::VerifiedUnlinked);
120-
debug::info!(target: LOG, "granting reputation to {:?}", sender);
120+
log::info!(target: LOG, "granting reputation to {:?}", sender);
121121
Ok(())
122122
}
123123

124124
#[weight = 10_000]
125125
pub fn register_participant(origin, cid: CommunityIdentifier, proof: Option<ProofOfAttendance<T::Signature, T::AccountId>>) -> DispatchResult {
126-
debug::RuntimeLogger::init();
127126
let sender = ensure_signed(origin)?;
128127
ensure!(<encointer_scheduler::Module<T>>::current_phase() == CeremonyPhaseType::REGISTERING,
129128
"registering participants can only be done during REGISTERING phase");
@@ -164,13 +163,12 @@ decl_module! {
164163
<ParticipantIndex<T>>::insert((cid, cindex), &sender, &new_count);
165164
<ParticipantCount>::insert((cid, cindex), new_count);
166165

167-
debug::debug!(target: LOG, "registered participant: {:?}", sender);
166+
log::debug!(target: LOG, "registered participant: {:?}", sender);
168167
Ok(())
169168
}
170169

171170
#[weight = 10_000]
172171
pub fn register_attestations(origin, attestations: Vec<Attestation<T::Signature, T::AccountId, T::Moment>>) -> DispatchResult {
173-
debug::RuntimeLogger::init();
174172
let sender = ensure_signed(origin)?;
175173
ensure!(<encointer_scheduler::Module<T>>::current_phase() == CeremonyPhaseType::ATTESTING,
176174
"registering attestations can only be done during ATTESTING phase");
@@ -193,57 +191,57 @@ decl_module! {
193191
{ l } else { return Err(<Error<T>>::MeetupLocationNotFound.into()) };
194192
let mtime = if let Some(t) = Self::get_meetup_time(&cid, meetup_index)
195193
{ t } else { return Err(<Error<T>>::MeetupTimeCalculationError.into()) };
196-
debug::debug!(target: LOG, "meetup {} at location {:?} should happen at {:?} for cid {:?}",
194+
log::debug!(target: LOG, "meetup {} at location {:?} should happen at {:?} for cid {:?}",
197195
meetup_index, mlocation, mtime, cid);
198196
for attestation in attestations.iter() {
199197
let attestation_account = &attestation.public;
200198
if !meetup_participants.contains(attestation_account) {
201-
debug::warn!(target: LOG,
199+
log::warn!(target: LOG,
202200
"ignoring attestation that isn't a meetup participant: {:?}",
203201
attestation_account);
204202
continue };
205203
if attestation.claim.ceremony_index != cindex {
206-
debug::warn!(target: LOG,
204+
log::warn!(target: LOG,
207205
"ignoring claim with wrong ceremony index: {}",
208206
attestation.claim.ceremony_index);
209207
continue };
210208
if attestation.claim.community_identifier != cid {
211-
debug::warn!(target: LOG,
209+
log::warn!(target: LOG,
212210
"ignoring claim with wrong community identifier: {:?}",
213211
attestation.claim.community_identifier);
214212
continue };
215213
if attestation.claim.meetup_index != meetup_index {
216-
debug::warn!(target: LOG,
214+
log::warn!(target: LOG,
217215
"ignoring claim with wrong meetup index: {}",
218216
attestation.claim.meetup_index);
219217
continue };
220218
if !<encointer_communities::Module<T>>::is_valid_geolocation(
221219
&attestation.claim.location) {
222-
debug::warn!(target: LOG,
220+
log::warn!(target: LOG,
223221
"ignoring claim with illegal geolocation: {:?}",
224222
attestation.claim.location);
225223
continue };
226224
if <encointer_communities::Module<T>>::haversine_distance(
227225
&mlocation, &attestation.claim.location) > Self::location_tolerance() {
228-
debug::warn!(target: LOG,
226+
log::warn!(target: LOG,
229227
"ignoring claim beyond location tolerance: {:?}",
230228
attestation.claim.location);
231229
continue };
232230
if let Some(dt) = mtime.checked_sub(&attestation.claim.timestamp) {
233231
if dt > Self::time_tolerance() {
234-
debug::warn!(target: LOG,
232+
log::warn!(target: LOG,
235233
"ignoring claim beyond time tolerance (too early): {:?}",
236234
attestation.claim.timestamp);
237235
continue };
238236
} else if let Some(dt) = attestation.claim.timestamp.checked_sub(&mtime) {
239237
if dt > Self::time_tolerance() {
240-
debug::warn!(target: LOG,
238+
log::warn!(target: LOG,
241239
"ignoring claim beyond time tolerance (too late): {:?}",
242240
attestation.claim.timestamp);
243241
continue };
244242
}
245243
if Self::verify_attestation_signature(attestation.clone()).is_err() {
246-
debug::warn!(target: LOG, "ignoring attestation with bad signature for {:?}", sender);
244+
log::warn!(target: LOG, "ignoring attestation with bad signature for {:?}", sender);
247245
continue };
248246
// attestation is legit. insert it!
249247
verified_attestation_accounts.insert(0, attestation_account.clone());
@@ -267,15 +265,14 @@ decl_module! {
267265
<AttestationRegistry<T>>::insert((cid, cindex), &idx, &verified_attestation_accounts);
268266
<AttestationIndex<T>>::insert((cid, cindex), &sender, &idx);
269267
<MeetupParticipantCountVote<T>>::insert((cid, cindex), &sender, &claim_n_participants);
270-
debug::debug!(target: LOG,
268+
log::debug!(target: LOG,
271269
"sucessfully registered {} attestations for {:?}",
272270
verified_attestation_accounts.len(), sender);
273271
Ok(())
274272
}
275273

276274
#[weight = 10_000]
277275
pub fn endorse_newcomer(origin, cid: CommunityIdentifier, newbie: T::AccountId) -> DispatchResult {
278-
debug::RuntimeLogger::init();
279276
let sender = ensure_signed(origin)?;
280277

281278
ensure!(<encointer_communities::Module<T>>::community_identifiers().contains(&cid),
@@ -295,7 +292,7 @@ decl_module! {
295292
"newbie is already endorsed");
296293

297294
<BurnedBootstrapperNewbieTickets<T>>::mutate(&cid, sender,|b| *b += 1);
298-
debug::debug!(target: LOG, "endorsed newbie: {:?}", newbie);
295+
log::debug!(target: LOG, "endorsed newbie: {:?}", newbie);
299296
<Endorsees<T>>::insert((cid, cindex), newbie, ());
300297
<EndorseesCount>::mutate((cid, cindex), |c| *c += 1);
301298
Ok(())
@@ -340,7 +337,7 @@ impl<T: Config> Module<T> {
340337
<AttestationCount>::insert((cid, cindex), 0);
341338
<MeetupParticipantCountVote<T>>::remove_prefix((cid, cindex));
342339
}
343-
debug::debug!(target: LOG, "purged registry for ceremony {}", cindex);
340+
log::debug!(target: LOG, "purged registry for ceremony {}", cindex);
344341
}
345342

346343
/* this is for a more recent revision of substrate....
@@ -401,7 +398,7 @@ impl<T: Config> Module<T> {
401398
n += endorsees.len();
402399

403400
if n < 3 {
404-
debug::debug!(target: LOG, "no meetups assigned for cid {:?}", cid);
401+
log::debug!(target: LOG, "no meetups assigned for cid {:?}", cid);
405402
continue;
406403
}
407404

@@ -410,7 +407,7 @@ impl<T: Config> Module<T> {
410407

411408
// capping the amount a participants prevents assigning more meetups than there are locations.
412409
if n > n_locations * 12 {
413-
debug::warn!(target: LOG, "Meetup Locations exhausted for cid: {:?}", cid);
410+
log::warn!(target: LOG, "Meetup Locations exhausted for cid: {:?}", cid);
414411
n = n_locations * 12;
415412
}
416413

@@ -446,14 +443,14 @@ impl<T: Config> Module<T> {
446443
<MeetupRegistry<T>>::insert((cid, cindex), &_idx, m.clone());
447444
}
448445
};
449-
debug::debug!(
446+
log::debug!(
450447
target: LOG,
451448
"assigned {} meetups for cid {:?}",
452449
meetups.len(),
453450
cid
454451
);
455452
}
456-
debug::debug!(target: LOG, "meetup assignments done");
453+
log::debug!(target: LOG, "meetup assignments done");
457454
}
458455

459456
fn verify_attestation_signature(
@@ -504,7 +501,7 @@ impl<T: Config> Module<T> {
504501
match Self::ballot_meetup_n_votes(cid, cindex, m) {
505502
Some(nn) => nn,
506503
_ => {
507-
debug::warn!(
504+
log::warn!(
508505
target: LOG,
509506
"ignoring meetup {} because votes are not dependable",
510507
m
@@ -515,7 +512,7 @@ impl<T: Config> Module<T> {
515512
let meetup_participants = Self::meetup_registry((cid, cindex), &m);
516513
for p in meetup_participants {
517514
if Self::meetup_participant_count_vote((cid, cindex), &p) != n_confirmed {
518-
debug::debug!(
515+
log::debug!(
519516
target: LOG,
520517
"skipped participant because of wrong participant count vote: {:?}",
521518
p
@@ -529,7 +526,7 @@ impl<T: Config> Module<T> {
529526
if attestations.len() < (n_honest_participants - 1) as usize
530527
|| attestations.is_empty()
531528
{
532-
debug::debug!(
529+
log::debug!(
533530
target: LOG,
534531
"skipped participant because of too few attestations ({}): {:?}",
535532
attestations.len(),
@@ -548,14 +545,14 @@ impl<T: Config> Module<T> {
548545
}
549546
}
550547
if has_attested < (n_honest_participants - 1) {
551-
debug::debug!(
548+
log::debug!(
552549
target: LOG,
553550
"skipped participant because didn't testify for honest peers: {:?}",
554551
p
555552
);
556553
continue;
557554
}
558-
debug::trace!(target: LOG, "participant merits reward: {:?}", p);
555+
log::trace!(target: LOG, "participant merits reward: {:?}", p);
559556
if <encointer_balances::Module<T>>::issue(*cid, &p, reward).is_ok() {
560557
<ParticipantReputation<T>>::insert(
561558
(cid, cindex),
@@ -566,7 +563,7 @@ impl<T: Config> Module<T> {
566563
}
567564
}
568565
}
569-
debug::info!(target: LOG, "issuing rewards completed");
566+
log::info!(target: LOG, "issuing rewards completed");
570567
}
571568

572569
fn ballot_meetup_n_votes(

communities/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = "0.3.9"
44
authors = ["encointer.org <[email protected]>"]
55
edition = "2018"
66

7+
[dependencies]
8+
log = { version = "0.4.14", default-features = false }
9+
710
[dependencies.encointer-primitives]
811
default-features = false
912
package = "encointer-primitives"

communities/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
// use host_calls::runtime_interfaces;
2727
use frame_support::{
28-
debug, decl_error, decl_event, decl_module, decl_storage,
28+
decl_error, decl_event, decl_module, decl_storage,
2929
dispatch::DispatchResult,
3030
ensure,
3131
storage::{StorageMap, StorageValue},
@@ -68,7 +68,6 @@ decl_module! {
6868
// this should be run off-chain in substraTEE-worker later
6969
#[weight = 10_000]
7070
pub fn new_community(origin, loc: Vec<Location>, bootstrappers: Vec<T::AccountId>) -> DispatchResult {
71-
debug::RuntimeLogger::init();
7271
let sender = ensure_signed(origin)?;
7372
let cid = CommunityIdentifier::from(blake2_256(&(loc.clone(), bootstrappers.clone()).encode()));
7473
let cids = Self::community_identifiers();
@@ -84,20 +83,20 @@ decl_module! {
8483
// prohibit proximity to poles
8584
if Self::haversine_distance(&l1, &NORTH_POLE) < DATELINE_DISTANCE_M
8685
|| Self::haversine_distance(&l1, &SOUTH_POLE) < DATELINE_DISTANCE_M {
87-
debug::warn!(target: LOG, "location too close to pole: {:?}", l1);
86+
log::warn!(target: LOG, "location too close to pole: {:?}", l1);
8887
return Err(<Error<T>>::MinimumDistanceViolationToPole.into());
8988
}
9089
// prohibit proximity to dateline
9190
let dateline_proxy = Location { lat: l1.lat, lon: DATELINE_LON };
9291
if Self::haversine_distance(&l1, &dateline_proxy) < DATELINE_DISTANCE_M {
93-
debug::warn!(target: LOG, "location too close to dateline: {:?}", l1);
92+
log::warn!(target: LOG, "location too close to dateline: {:?}", l1);
9493
return Err(<Error<T>>::MinimumDistanceViolationToDateLine.into());
9594
}
9695
// test against all other communities globally
9796
for other in cids.iter() {
9897
for l2 in Self::locations(other) {
9998
if Self::solar_trip_time(&l1, &l2) < MIN_SOLAR_TRIP_TIME_S {
100-
debug::warn!(target: LOG,
99+
log::warn!(target: LOG,
101100
"location {:?} too close to previously registered location {:?} with cid {:?}",
102101
l1, l2, other);
103102
return Err(<Error<T>>::MinimumDistanceViolationToOtherCommunity.into());
@@ -117,7 +116,7 @@ decl_module! {
117116
}
118117
);
119118
Self::deposit_event(RawEvent::CommunityRegistered(sender, cid));
120-
debug::info!(target: LOG, "registered community with cid: {:?}", cid);
119+
log::info!(target: LOG, "registered community with cid: {:?}", cid);
121120
Ok(())
122121
}
123122
}

personhood-oracle/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = "0.3.9"
44
authors = ["encointer.org <[email protected]>"]
55
edition = "2018"
66

7+
[dependencies]
8+
log = { version = "0.4.14", default-features = false }
9+
710
[dependencies.encointer-primitives]
811
default-features = false
912
package = "encointer-primitives"

personhood-oracle/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,15 @@ decl_module! {
8383
requested_response: u8,
8484
sender_sybil_gate: u8
8585
) {
86-
debug::RuntimeLogger::init();
8786
let sender = ensure_signed(origin)?;
8887
let para_id: u32 = Sibling::try_from_account(&sender)
8988
.ok_or(<Error<T>>::UnableToDecodeRequest)?
9089
.into();
9190
let request = <Vec<ProofOfAttendanceOf<T>>>::decode(&mut rating_request.as_slice())
9291
.map_err(|_| <Error<T>>::UnableToDecodeRequest)?;
9392

94-
debug::debug!(target: LOG, "received proof of personhood-oracle from parachain: {:?}", para_id);
95-
debug::debug!(target: LOG, "received proof of personhood-oracle request: {:?}", request);
93+
log::debug!(target: LOG, "received proof of personhood-oracle from parachain: {:?}", para_id);
94+
log::debug!(target: LOG, "received proof of personhood-oracle request: {:?}", request);
9695

9796
let confidence = Self::verify(request).unwrap_or_else(|_| PersonhoodUniquenessRating::default());
9897

@@ -130,7 +129,7 @@ impl<T: Config> Module<T> {
130129
if !<encointer_communities::Module<T>>::community_identifiers()
131130
.contains(&proof.community_identifier)
132131
{
133-
debug::warn!(
132+
log::warn!(
134133
target: LOG,
135134
"Received ProofOfAttendance for unknown cid: {:?}",
136135
proof.community_identifier

0 commit comments

Comments
 (0)