Use tracing as log when tracing enabled

This commit is contained in:
Mingwei Samuel 2021-07-23 15:40:55 -07:00
parent 8dbcca434d
commit 00e520b7af
6 changed files with 37 additions and 14 deletions

View file

@ -1,7 +1,11 @@
use std::cmp; use std::cmp;
use std::time::{ Duration, Instant }; use std::time::{ Duration, Instant };
#[cfg(not(feature="tracing"))]
use log; use log;
#[cfg(feature="tracing")]
use tracing as log;
use parking_lot::{ RwLock, RwLockUpgradableReadGuard }; use parking_lot::{ RwLock, RwLockUpgradableReadGuard };
use reqwest::{ StatusCode, Response }; use reqwest::{ StatusCode, Response };
use scan_fmt::scan_fmt; use scan_fmt::scan_fmt;

View file

@ -1,11 +1,15 @@
use std::future::Future; use std::future::Future;
use std::sync::Arc; use std::sync::Arc;
#[cfg(not(feature="tracing"))]
use log; use log;
use reqwest::{ StatusCode, RequestBuilder }; #[cfg(feature="tracing")]
use tracing as log;
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
use tracing::Instrument; use tracing::Instrument;
use reqwest::{ StatusCode, RequestBuilder };
use crate::util::InsertOnlyCHashMap; use crate::util::InsertOnlyCHashMap;
use crate::ResponseInfo; use crate::ResponseInfo;
use crate::Result; use crate::Result;

View file

@ -1,7 +1,11 @@
use std::future::Future; use std::future::Future;
use std::sync::Arc; use std::sync::Arc;
#[cfg(not(feature="tracing"))]
use log; use log;
#[cfg(feature="tracing")]
use tracing as log;
use reqwest::{ Client, RequestBuilder, Method }; use reqwest::{ Client, RequestBuilder, Method };
use crate::Result; use crate::Result;

12
test-full.bash Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
set -ex
# Ensure stable builds.
cargo +stable test --no-run
cargo +stable test --no-run --features tracing
# Ensure nightly builds.
cargo +nightly test --no-run --features nightly,tracing
# Run tests on nightly.
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=trace cargo +nightly test --features nightly -- --nocapture

View file

@ -1,5 +1,3 @@
#!/bin/bash #!/bin/bash
set -e set -ex
cargo +stable test --no-run
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=trace cargo +nightly test --features nightly -- --nocapture RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=trace cargo +nightly test --features nightly -- --nocapture

View file

@ -49,16 +49,17 @@ async_tests!{
Ok(()) Ok(())
}, },
// tft-league-v1.getLeagueEntriesForSummoner // Disabled: Caihonbbt no longer ranked.
// https://github.com/MingweiSamuel/Riven/issues/25 // // tft-league-v1.getLeagueEntriesForSummoner
tft_league_getleagueentriesforsummoner: async { // // https://github.com/MingweiSamuel/Riven/issues/25
let sp = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "Caihonbbt"); // tft_league_getleagueentriesforsummoner: async {
let sr = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"Caihonbbt\"".to_owned())?; // let sp = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "Caihonbbt");
let lp = RIOT_API.tft_league_v1().get_league_entries_for_summoner(ROUTE, &sr.id); // let sr = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"Caihonbbt\"".to_owned())?;
let lr = lp.await.map_err(|e| e.to_string())?; // let lp = RIOT_API.tft_league_v1().get_league_entries_for_summoner(ROUTE, &sr.id);
rassert!(0 < lr.len()); // let lr = lp.await.map_err(|e| e.to_string())?;
Ok(()) // rassert!(0 < lr.len());
}, // Ok(())
// },
// tft-league-v1.getTopRatedLadder // tft-league-v1.getTopRatedLadder
// https://github.com/MingweiSamuel/Riven/issues/24 // https://github.com/MingweiSamuel/Riven/issues/24
tft_league_gettopratedladder: async { tft_league_gettopratedladder: async {