Replace log with tracing

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/51/head
trivernis 2 years ago
parent 0952e630ed
commit 2ffdd1c9f9
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

191
Cargo.lock generated

@ -38,6 +38,15 @@ dependencies = [
"thiserror",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "arrayvec"
version = "0.4.12"
@ -129,17 +138,6 @@ dependencies = [
"tungstenite 0.16.0",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "audiopus"
version = "0.2.0"
@ -332,17 +330,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]]
name = "command_attr"
version = "0.3.8"
@ -476,6 +463,17 @@ dependencies = [
"num_cpus",
]
[[package]]
name = "dashmap"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8858831f7781322e539ea39e72449c46b059638250c14344fec8d0aa6e539c"
dependencies = [
"cfg-if 1.0.0",
"num_cpus",
"parking_lot 0.12.0",
]
[[package]]
name = "derive_more"
version = "0.99.17"
@ -603,15 +601,6 @@ dependencies = [
"instant",
]
[[package]]
name = "fern"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9a4820f0ccc8a7afd67c39a0f1a0f4b07ca1725164271a64939d7aeb9af065"
dependencies = [
"log",
]
[[package]]
name = "flate2"
version = "1.0.22"
@ -1079,9 +1068,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
name = "js-sys"
version = "0.3.56"
version = "0.3.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04"
checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397"
dependencies = [
"wasm-bindgen",
]
@ -1093,10 +1082,9 @@ source = "git+https://gitlab.com/vicky5124/lavalink-rs/?rev=2487c295#2487c2953c7
dependencies = [
"async-trait",
"async-tungstenite 0.16.1",
"dashmap",
"dashmap 4.0.2",
"futures",
"http",
"log",
"parking_lot 0.12.0",
"regex",
"reqwest",
@ -1107,6 +1095,7 @@ dependencies = [
"songbird",
"tokio",
"tokio-native-tls",
"tracing",
"typemap_rev",
"version_check",
]
@ -1119,9 +1108,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.121"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
[[package]]
name = "lock_api"
@ -1187,6 +1176,15 @@ dependencies = [
"xml5ever",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "matches"
version = "0.1.9"
@ -1838,6 +1836,15 @@ dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
@ -1892,7 +1899,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.22.2",
"webpki-roots 0.22.3",
"winreg",
]
@ -2256,16 +2263,17 @@ dependencies = [
[[package]]
name = "serenity-rich-interaction"
version = "0.2.6"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9bc8919bb2b46d927f1810a47a030cfa62a720fe6ef33b68bbdbc39394fe001"
checksum = "b7468dce50adc3f39e3fc65606cfe660148958b36d1f54454b845cbf710de02b"
dependencies = [
"dashmap 5.2.0",
"futures",
"log",
"serde_json",
"serenity",
"thiserror",
"tokio",
"tracing",
]
[[package]]
@ -2304,6 +2312,15 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
@ -2351,7 +2368,7 @@ dependencies = [
"async-tungstenite 0.14.0",
"audiopus",
"byteorder",
"dashmap",
"dashmap 4.0.2",
"discortp",
"flume",
"futures",
@ -2486,9 +2503,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.23.8"
version = "0.23.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad04c584871b8dceb769a20b94e26a357a870c999b7246dcd4cb233d927547e3"
checksum = "b3fb8adaa82317f1e8a040281807f411803c9111303cfe129b4abb4a14b2c223"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
@ -2550,6 +2567,15 @@ dependencies = [
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.1.44"
@ -2587,13 +2613,10 @@ dependencies = [
"build-time",
"chrono",
"chrono-tz",
"colored",
"dotenv",
"fern",
"futures",
"lavalink-rs",
"lazy_static",
"log",
"minecraft-data-rs",
"rand 0.8.5",
"regex",
@ -2609,6 +2632,8 @@ dependencies = [
"sysinfo",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"trigram",
"typemap_rev",
"xkcd-search",
@ -2725,9 +2750,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
version = "0.1.32"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f"
checksum = "80b9fa4360528139bc96100c160b7ae879f5567f49f1782b0b02035b0358ebf3"
dependencies = [
"cfg-if 1.0.0",
"log",
@ -2754,6 +2779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90442985ee2f57c9e1b548ee72ae842f4a9a20e3f417cc38dbc5dc684d9bb4ee"
dependencies = [
"lazy_static",
"valuable",
]
[[package]]
@ -2766,6 +2792,35 @@ dependencies = [
"tracing",
]
[[package]]
name = "tracing-log"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596"
dependencies = [
"ansi_term",
"lazy_static",
"matchers",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "trigram"
version = "0.4.4"
@ -2957,6 +3012,12 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
@ -2999,9 +3060,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.79"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06"
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -3009,9 +3070,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.79"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
dependencies = [
"bumpalo",
"lazy_static",
@ -3024,9 +3085,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.29"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395"
checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@ -3036,9 +3097,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.79"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -3046,9 +3107,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.79"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
dependencies = [
"proc-macro2",
"quote",
@ -3059,15 +3120,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.79"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
[[package]]
name = "web-sys"
version = "0.3.56"
version = "0.3.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb"
checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -3113,9 +3174,9 @@ dependencies = [
[[package]]
name = "webpki-roots"
version = "0.22.2"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449"
checksum = "44d8de8415c823c8abd270ad483c6feeac771fad964890779f9a8cb24fbbc1bf"
dependencies = [
"webpki 0.22.0",
]

@ -15,7 +15,6 @@ panic = 'abort'
[dependencies]
bot-database = {path="./bot-database"}
bot-coreutils = {path="./bot-coreutils"}
serenity-rich-interaction = "0.2.6"
serenity = "0.10.10"
dotenv = "0.15.0"
serde_derive = "1.0.136"
@ -29,10 +28,7 @@ regex = "1.5.5"
aspotify = "0.7.1"
lazy_static = "1.4.0"
futures = "0.3.21"
log = "0.4.16"
fern = "0.6.0"
chrono = "0.4.19"
colored = "2.0.0"
sysinfo = "0.23.8"
reqwest = "0.11.10"
chrono-tz = "0.6.1"
@ -44,6 +40,11 @@ youtube-metadata = "0.2.0"
xkcd-search = "0.1.2"
animethemes-rs = "0.3.0"
build-time = "0.1.1"
tracing-subscriber = {version = "0.3.10", features = ["env-filter"] }
tracing = "0.1.32"
[dependencies.serenity-rich-interaction]
version = "0.3.0"
[dependencies.tokio]
version = "1.17.0"
@ -52,5 +53,5 @@ features = ["macros", "rt-multi-thread"]
[dependencies.lavalink-rs]
git = "https://gitlab.com/vicky5124/lavalink-rs/"
rev = "2487c295"
features=["native", "serenity", "songbird", "normal-log"]
features=["native", "serenity", "songbird", "tracing-log"]
default-features = false

@ -102,7 +102,7 @@ async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: Command
m.embed(|e| e.title("Error occurred").description(format!("{}", why)))
})
.await;
log::warn!("Error in {}: {:?}", cmd_name, why);
tracing::warn!("Error in {}: {:?}", cmd_name, why);
}
let database = get_database_from_context(ctx).await;
let _ = database
@ -118,7 +118,7 @@ async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: Command
#[hook]
async fn before_hook(ctx: &Context, msg: &Message, _: &str) -> bool {
log::trace!("Got command message {}", msg.content);
tracing::trace!("Got command message {}", msg.content);
let _ = msg.channel_id.broadcast_typing(ctx).await;
true
}

@ -16,7 +16,7 @@ pub(crate) async fn enchantment(ctx: &Context, msg: &Message, args: Args) -> Com
let data = ctx.data.read().await;
let store = data.get::<Store>().expect("Failed to get store");
let enchantment_name = args.message().to_lowercase();
log::debug!("Searching for enchantment {}", enchantment_name);
tracing::debug!("Searching for enchantment {}", enchantment_name);
let enchantments_by_name = store
.minecraft_data_api
@ -29,7 +29,7 @@ pub(crate) async fn enchantment(ctx: &Context, msg: &Message, args: Args) -> Com
enchantment_name
)))?
.clone();
log::trace!("Enchantment is {:?}", enchantment);
tracing::trace!("Enchantment is {:?}", enchantment);
msg.channel_id
.send_message(ctx, |m| {

@ -19,9 +19,9 @@ pub(crate) async fn item(ctx: &Context, msg: &Message, args: Args) -> CommandRes
let store = data.get::<Store>().expect("Failed to get store");
let item_name = args.message().to_lowercase();
log::debug!("Searching for item '{}'", item_name);
tracing::debug!("Searching for item '{}'", item_name);
let information = get_item_full_information(&item_name, &store.minecraft_data_api)?;
log::trace!("Item full information is {:?}", information);
tracing::trace!("Item full information is {:?}", information);
create_item_message(ctx, msg.channel_id, information).await?;
handle_autodelete(ctx, msg).await?;

@ -17,17 +17,17 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[required_permissions("MANAGE_MESSAGES")]
async fn clear(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let limit = args.single::<u64>().unwrap_or(20);
log::debug!("Deleting messages for channel {}", msg.channel_id);
tracing::debug!("Deleting messages for channel {}", msg.channel_id);
let messages = msg.channel_id.messages(ctx, |b| b.limit(limit)).await?;
log::debug!("Deleting {} messages", messages.len());
tracing::debug!("Deleting {} messages", messages.len());
let futures: Vec<BoxFuture<SerenityResult<()>>> = messages
.into_iter()
.map(|m| async move { ctx.http.delete_message(m.channel_id.0, m.id.0).await }.boxed())
.collect();
log::debug!("Waiting for all messages to be deleted");
tracing::debug!("Waiting for all messages to be deleted");
let deleted = futures::future::join_all(futures).await;
let deleted_count = deleted.into_iter().filter(|d| d.is_ok()).count();
log::debug!("{} Messages deleted", deleted_count);
tracing::debug!("{} Messages deleted", deleted_count);
EphemeralMessage::create(&ctx.http, msg.channel_id, SHORT_TIMEOUT, |f| {
f.content(format!("Deleted {} messages", deleted_count))

@ -17,7 +17,7 @@ static NOT_FOUND_PAIN: &str = "404";
#[max_args(1)]
#[bucket("general")]
async fn pain(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
log::debug!("Got pain command");
tracing::debug!("Got pain command");
let pain_type = args.message().to_lowercase();
let database = get_database_from_context(ctx).await;
let mut media = database
@ -25,7 +25,7 @@ async fn pain(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
.await?;
if media.is_empty() {
log::debug!("No media found for pain {}. Using 404", pain_type);
tracing::debug!("No media found for pain {}. Using 404", pain_type);
media = database
.get_media_by_category(format!("{}{}", CATEGORY_PREFIX, NOT_FOUND_PAIN))
.await?;
@ -35,7 +35,7 @@ async fn pain(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
.into_iter()
.choose(&mut rand::thread_rng())
.ok_or(BotError::from("No gifs found."))?;
log::trace!("Gif for pain is {:?}", entry);
tracing::trace!("Gif for pain is {:?}", entry);
msg.reply(ctx, entry.url).await?;
Ok(())

@ -15,7 +15,7 @@ use crate::commands::common::handle_autodelete;
#[owners_only]
async fn shutdown(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let code = args.single::<i32>().unwrap_or(0);
log::info!("Shutting down with code {}...", code);
tracing::info!("Shutting down with code {}...", code);
msg.channel_id
.say(
ctx,

@ -16,7 +16,7 @@ use crate::utils::context_data::{get_database_from_context, MusicPlayers};
#[usage("")]
#[bucket("general")]
async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
log::debug!("Reading system stats");
tracing::debug!("Reading system stats");
let database = get_database_from_context(ctx).await;
let mut system = sysinfo::System::new_all();
system.refresh_all();
@ -56,7 +56,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
total_commands_executed
);
log::trace!("Discord info {}", discord_info);
tracing::trace!("Discord info {}", discord_info);
let system_info = format!(
r#"
@ -74,7 +74,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult {
uptime.num_hours() % 24,
uptime.num_minutes() % 60
);
log::trace!("System info {}", system_info);
tracing::trace!("System info {}", system_info);
msg.channel_id
.send_message(ctx, |m| {

@ -18,7 +18,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn clear_queue(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Clearing queue for guild {}", guild.id);
tracing::debug!("Clearing queue for guild {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player

@ -17,7 +17,7 @@ use crate::messages::music::now_playing::create_now_playing_msg;
async fn current(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Displaying current song for queue in {}", guild.id);
tracing::debug!("Displaying current song for queue in {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player
} else {

@ -19,7 +19,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn equalize(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Changing equalizer for {}", guild.id);
tracing::debug!("Changing equalizer for {}", guild.id);
let preset = args.single::<String>().unwrap();
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {

@ -16,7 +16,7 @@ use crate::messages::music::no_voicechannel::create_no_voicechannel_message;
#[checks(DJ)]
async fn equalizer(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Displaying equalizer for guild {}", guild.id);
tracing::debug!("Displaying equalizer for guild {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player

@ -41,7 +41,7 @@ async fn join(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
.await?;
return Ok(());
}
log::debug!("Joining channel {} for guild {}", channel_id, guild.id);
tracing::debug!("Joining channel {} for guild {}", channel_id, guild.id);
MusicPlayer::join(ctx, guild.id, channel_id, msg.channel_id).await?;
EphemeralMessage::create(&ctx.http, msg.channel_id, SHORT_TIMEOUT, |m| {
m.content("🎤 Joined the Voice Channel")

@ -18,7 +18,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Leave request received for guild {}", guild.id);
tracing::debug!("Leave request received for guild {}", guild.id);
let manager = songbird::get(ctx).await.unwrap();
if let Some(handler) = manager.get(guild.id) {

@ -14,7 +14,7 @@ use crate::messages::music::no_voicechannel::create_no_voicechannel_message;
#[bucket("general")]
async fn lyrics(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Fetching lyrics for song playing in {}", guild.id);
tracing::debug!("Fetching lyrics for song playing in {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player
@ -46,7 +46,7 @@ async fn lyrics(ctx: &Context, msg: &Message) -> CommandResult {
})
.await?;
} else {
log::debug!("No lyrics found");
tracing::debug!("No lyrics found");
msg.channel_id.say(ctx, "No lyrics found").await?;
}

@ -126,23 +126,23 @@ async fn get_songs_for_query(ctx: &Context, msg: &Message, query: &str) -> BotRe
let store = data.get::<Store>().unwrap();
let database = data.get::<DatabaseContainer>().unwrap();
log::debug!("Querying play input {}", query);
tracing::debug!("Querying play input {}", query);
if let Some(captures) = PLAYLIST_NAME_REGEX.captures(&query) {
log::debug!("Query is a saved playlist");
tracing::debug!("Query is a saved playlist");
let pl_name: &str = captures.get(1).unwrap().as_str();
log::trace!("Playlist name is {}", pl_name);
tracing::trace!("Playlist name is {}", pl_name);
let playlist_opt = database
.get_guild_playlist(guild_id.0, pl_name.to_string())
.await?;
log::trace!("Playlist is {:?}", playlist_opt);
tracing::trace!("Playlist is {:?}", playlist_opt);
if let Some(playlist) = playlist_opt {
log::debug!("Assigning url for saved playlist to query");
tracing::debug!("Assigning url for saved playlist to query");
query = playlist.url;
}
}
if YOUTUBE_URL_REGEX.is_match(&query) {
log::debug!("Query is youtube video or playlist");
tracing::debug!("Query is youtube video or playlist");
// try fetching the url as a playlist
songs = youtube_dl::get_videos_for_playlist(&query)
.await?
@ -152,18 +152,18 @@ async fn get_songs_for_query(ctx: &Context, msg: &Message, query: &str) -> BotRe
// if no songs were found fetch the song as a video
if songs.len() == 0 {
log::debug!("Query is youtube video");
tracing::debug!("Query is youtube video");
let mut song: Song = get_video_information(&query).await?.into();
added_one_msg(&ctx, msg, &mut song).await?;
add_youtube_song_to_database(&store, &database, &mut song).await?;
songs.push(song);
} else {
log::debug!("Query is playlist with {} songs", songs.len());
tracing::debug!("Query is playlist with {} songs", songs.len());
added_multiple_msg(&ctx, msg, &mut songs).await?;
}
} else if SPOTIFY_PLAYLIST_REGEX.is_match(&query) {
// search for all songs in the playlist and search for them on youtube
log::debug!("Query is spotify playlist");
tracing::debug!("Query is spotify playlist");
let tracks = store.spotify_api.get_songs_in_playlist(&query).await?;
let futures: Vec<BoxFuture<Song>> = tracks
@ -183,7 +183,7 @@ async fn get_songs_for_query(ctx: &Context, msg: &Message, query: &str) -> BotRe
added_multiple_msg(&ctx, msg, &mut songs).await?;
} else if SPOTIFY_ALBUM_REGEX.is_match(&query) {
// fetch all songs in the album and search for them on youtube
log::debug!("Query is spotify album");
tracing::debug!("Query is spotify album");
let tracks = store.spotify_api.get_songs_in_album(&query).await?;
for track in tracks {
@ -197,7 +197,7 @@ async fn get_songs_for_query(ctx: &Context, msg: &Message, query: &str) -> BotRe
added_multiple_msg(&ctx, msg, &mut songs).await?;
} else if SPOTIFY_SONG_REGEX.is_match(&query) {
// fetch the song name and search it on youtube
log::debug!("Query is a spotify song");
tracing::debug!("Query is a spotify song");
let track = store.spotify_api.get_track_for_url(&query).await?;
let mut song = get_youtube_song_for_track(&database, track.clone())
.await?
@ -205,12 +205,12 @@ async fn get_songs_for_query(ctx: &Context, msg: &Message, query: &str) -> BotRe
added_one_msg(ctx, msg, &mut song).await?;
songs.push(song);
} else {
log::debug!("Query is a youtube search");
tracing::debug!("Query is a youtube search");
let mut song: Song = youtube_dl::search_video_information(query.clone())
.await?
.ok_or(BotError::Msg(format!("Noting found for {}", query)))?
.into();
log::trace!("Search result is {:?}", song);
tracing::trace!("Search result is {:?}", song);
added_one_msg(&ctx, msg, &mut song).await?;
songs.push(song);
@ -291,24 +291,24 @@ pub async fn is_dj(ctx: &Context, guild: GuildId, user: &User) -> BotResult<bool
/// Searches for a matching youtube song for the given track in the local database
async fn get_youtube_song_for_track(database: &Database, track: Track) -> BotResult<Option<Song>> {
log::debug!("Trying to find track in database.");
tracing::debug!("Trying to find track in database.");
if let Some(id) = track.id {
let entry = database.get_song(&id).await?;
if let Some(song) = entry {
// check if the video is still available
log::trace!("Found entry is {:?}", song);
tracing::trace!("Found entry is {:?}", song);
if let Ok(info) = get_video_information(&song.url).await {
return Ok(Some(info.into()));
} else {
log::debug!("Video '{}' is not available. Deleting entry", song.url);
tracing::debug!("Video '{}' is not available. Deleting entry", song.url);
database.delete_song(song.id).await?;
return Ok(None);
}
}
Ok(None)
} else {
log::debug!("Track has no ID");
tracing::debug!("Track has no ID");
Ok(None)
}
}

@ -19,7 +19,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn move_song(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Moving song for guild {}", guild.id);
tracing::debug!("Moving song for guild {}", guild.id);
let pos1 = args.single::<usize>()?;
let pos2 = args.single::<usize>()?;

@ -17,7 +17,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn pause(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Pausing playback for guild {}", guild.id);
tracing::debug!("Pausing playback for guild {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player
@ -33,14 +33,14 @@ async fn pause(ctx: &Context, msg: &Message) -> CommandResult {
let is_paused = player.is_paused();
if is_paused {
log::debug!("Paused");
tracing::debug!("Paused");
EphemeralMessage::create(&ctx.http, msg.channel_id, SHORT_TIMEOUT, |m| {
m.content("⏸️ Paused playback")
})
.await?;
player.update_now_playing().await?;
} else {
log::debug!("Resumed");
tracing::debug!("Resumed");
EphemeralMessage::create(&ctx.http, msg.channel_id, SHORT_TIMEOUT, |m| {
m.content("▶ Resumed playback")
})

@ -23,12 +23,12 @@ async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let query = args.message();
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Play request received for guild {}", guild.id);
tracing::debug!("Play request received for guild {}", guild.id);
let mut player = get_music_player_for_guild(ctx, guild.id).await;
if player.is_none() {
log::debug!("Not in a channel. Joining authors channel...");
tracing::debug!("Not in a channel. Joining authors channel...");
let channel_id = get_channel_for_author(&msg.author.id, &guild)?;
let music_player = MusicPlayer::join(ctx, guild.id, channel_id, msg.channel_id).await?;
player = Some(music_player);
@ -37,7 +37,7 @@ async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let songs = get_songs_for_query(&ctx, msg, query).await?;
let (play_first, create_now_playing) = {
log::debug!("Adding song to queue");
tracing::debug!("Adding song to queue");
let mut player_lock = player.lock().await;
for song in songs {
player_lock.queue().add(song);
@ -47,7 +47,7 @@ async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
.unwrap_or(false);
if autoshuffle {
log::debug!("Autoshuffeling");
tracing::debug!("Autoshuffeling");
player_lock.queue().shuffle();
}
(
@ -57,7 +57,7 @@ async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
};
if play_first {
log::debug!("Playing first song in queue");
tracing::debug!("Playing first song in queue");
let mut player_lock = player.lock().await;
player_lock.play_next().await?;
}

@ -23,12 +23,12 @@ async fn play_next(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let query = args.message();
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Playing song as next song for guild {}", guild.id);
tracing::debug!("Playing song as next song for guild {}", guild.id);
let mut player = get_music_player_for_guild(ctx, guild.id).await;
if player.is_none() {
log::debug!("Not in a channel. Joining authors channel...");
tracing::debug!("Not in a channel. Joining authors channel...");
let channel_id = get_channel_for_author(&msg.author.id, &guild)?;
let music_player = MusicPlayer::join(ctx, guild.id, channel_id, msg.channel_id).await?;
player = Some(music_player);
@ -40,7 +40,7 @@ async fn play_next(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let (play_first, create_now_playing) = {
let mut player_lock = player.lock().await;
songs.reverse();
log::debug!("Enqueueing songs as next songs in the queue");
tracing::debug!("Enqueueing songs as next songs in the queue");
for song in songs {
player_lock.queue().add_next(song);

@ -13,7 +13,7 @@ use crate::utils::context_data::get_database_from_context;
#[bucket("general")]
async fn playlists(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Displaying playlists for guild {}", guild.id);
tracing::debug!("Displaying playlists for guild {}", guild.id);
let database = get_database_from_context(ctx).await;
let playlists = database.get_guild_playlists(guild.id.0).await?;

@ -17,7 +17,7 @@ use crate::providers::music::queue::Song;
#[bucket("general")]
async fn queue(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::trace!("Displaying queue for guild {}", guild.id);
tracing::trace!("Displaying queue for guild {}", guild.id);
let query = args
.iter::<String>()
@ -53,7 +53,7 @@ async fn queue(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
})
.map(|(i, s)| (i, s.clone()))
.collect();
log::trace!("Songs are {:?}", songs);
tracing::trace!("Songs are {:?}", songs);
if songs.len() == 0 {
msg.channel_id

@ -19,7 +19,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn remove_song(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Moving song for guild {}", guild.id);
tracing::debug!("Moving song for guild {}", guild.id);
let pos = args.single::<usize>()?;
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {

@ -20,7 +20,7 @@ async fn save_playlist(ctx: &Context, msg: &Message, mut args: Args) -> CommandR
let name: String = args.single().unwrap();
let url: &str = args.remains().unwrap();
log::debug!(
tracing::debug!(
"Adding playlist '{}' with url '{}' to guild {}",
name,
url,

@ -19,7 +19,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
async fn shuffle(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Shuffling queue for guild {}", guild.id);
tracing::debug!("Shuffling queue for guild {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player
} else {

@ -18,7 +18,7 @@ use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
#[checks(DJ)]
async fn skip(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Skipping song for guild {}", guild.id);
tracing::debug!("Skipping song for guild {}", guild.id);
let player = if let Some(player) = get_music_player_for_guild(ctx, guild.id).await {
player

@ -18,10 +18,10 @@ use crate::utils::context_data::get_database_from_context;
async fn get(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let database = get_database_from_context(ctx).await;
let guild = msg.guild(&ctx.cache).await.unwrap();
log::debug!("Displaying guild setting for guild {}", guild.id);
tracing::debug!("Displaying guild setting for guild {}", guild.id);
if let Some(key) = args.single::<String>().ok() {
log::debug!("Displaying guild setting of '{}'", key);
tracing::debug!("Displaying guild setting of '{}'", key);
let setting = database
.get_guild_setting::<String>(guild.id.0, key.clone())
.await?;
@ -39,7 +39,7 @@ async fn get(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
}
}
} else {
log::debug!("Displaying all guild settings");
tracing::debug!("Displaying all guild settings");
let mut kv_pairs = Vec::new();
for key in ALL_SETTINGS {

@ -43,7 +43,7 @@ async fn pekofy(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
return Err(CommandError::from("Can't pekofy empty message"));
}
log::debug!("Pekofying message '{}'", content);
tracing::debug!("Pekofying message '{}'", content);
let mut alpha_lowercase = content.to_lowercase();
alpha_lowercase.retain(|c| c.is_alphanumeric());
@ -64,7 +64,7 @@ async fn pekofy(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
.http
.get_message(msg.channel_id.0, reference_message.0)
.await?;
log::debug!("Pekofied message is '{}'", pekofied);
tracing::debug!("Pekofied message is '{}'", pekofied);
message.reply(ctx, pekofied).await?;
Ok(())
@ -73,7 +73,7 @@ async fn pekofy(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
/// Pekofies a single line
fn pekofy_line(mut line: &str) -> String {
lazy_static::lazy_static! { static ref FORMATTING_REGEX: Regex = Regex::new(r"^(.*?)((<:\w+:\d+>|\W)*)$").unwrap(); }
log::debug!("Pekofying line '{}'", line);
tracing::debug!("Pekofying line '{}'", line);
let original = line;
let mut md = "";
@ -84,7 +84,7 @@ fn pekofy_line(mut line: &str) -> String {
for peko in PEKOS {
if line.to_lowercase().ends_with(peko) {
log::debug!("Peko already found in message. Returning original");
tracing::debug!("Peko already found in message. Returning original");
return original.to_string();
}
}
@ -96,7 +96,7 @@ fn pekofy_line(mut line: &str) -> String {
.filter(|c| c.is_alphabetic())
.all(char::is_uppercase)
{
log::debug!("Message is all uppercase. Peko will also be uppercase");
tracing::debug!("Message is all uppercase. Peko will also be uppercase");
peko = peko.to_uppercase();
}

@ -16,17 +16,17 @@ use crate::utils::get_previous_message_or_reply;
#[aliases("source")]
#[bucket("sauce_api")]
async fn sauce(ctx: &Context, msg: &Message) -> CommandResult {
log::debug!("Got sauce command");
tracing::debug!("Got sauce command");
let source_msg = get_previous_message_or_reply(ctx, msg).await?;
if source_msg.is_none() {
log::debug!("No source message provided");
tracing::debug!("No source message provided");
msg.channel_id.say(ctx, "No source message found.").await?;
return Ok(());
}
let source_msg = source_msg.unwrap();
log::trace!("Source message is {:?}", source_msg);
log::debug!("Getting attachments...");
tracing::trace!("Source message is {:?}", source_msg);
tracing::debug!("Getting attachments...");
let mut attachment_urls: Vec<String> = source_msg
.attachments
.into_iter()
@ -34,7 +34,7 @@ async fn sauce(ctx: &Context, msg: &Message) -> CommandResult {
.filter(|url| url::is_image(url) || url::is_video(url))
.collect();
log::debug!("Getting embedded images...");
tracing::debug!("Getting embedded images...");
let mut embed_images = source_msg
.embeds
.into_iter()
@ -43,17 +43,17 @@ async fn sauce(ctx: &Context, msg: &Message) -> CommandResult {
.collect::<Vec<String>>();
attachment_urls.append(&mut embed_images);
log::trace!("Image urls {:?}", attachment_urls);
tracing::trace!("Image urls {:?}", attachment_urls);
if attachment_urls.is_empty() {
log::debug!("No images in source image");
tracing::debug!("No images in source image");
msg.channel_id
.say(ctx, "I could not find any images in the message.")
.await?;
return Ok(());
}
log::debug!(
tracing::debug!(
"Checking SauceNao for {} attachments",
attachment_urls.len()
);
@ -63,12 +63,12 @@ async fn sauce(ctx: &Context, msg: &Message) -> CommandResult {
.sauce_nao
.check_sauces(&attachment_urls[..])
.await?;
log::trace!("Sources are {:?}", sources);
tracing::trace!("Sources are {:?}", sources);
log::debug!("Creating menu...");
tracing::debug!("Creating menu...");
show_sauce_menu(ctx, msg, sources).await?;
log::debug!("Menu created");
tracing::debug!("Menu created");
Ok(())
}

@ -22,7 +22,7 @@ pub fn get_raw_event_handler() -> RichEventHandler {
.add_event(|ctx, e: &event::ReadyEvent| Box::pin(ready(ctx, &e.ready)))
.add_event(|_ctx, _: &event::ResumedEvent| {
Box::pin(async {
log::info!("Reconnected to Gateway");
tracing::info!("Reconnected to Gateway");
Ok(())
})
});
@ -31,7 +31,7 @@ pub fn get_raw_event_handler() -> RichEventHandler {
}
async fn ready(ctx: &Context, _: &Ready) -> Result<()> {
log::info!("Ready");
tracing::info!("Ready");
delete_messages_from_database(&ctx).await?;
let prefix = std::env::var("BOT_PREFIX").unwrap_or("~!".to_string());
ctx.set_activity(Activity::listening(format!("{}help", prefix).as_str()))
@ -44,7 +44,7 @@ pub(crate) struct Handler;
#[async_trait]
impl EventHandler for Handler {
async fn resume(&self, _: Context, _: ResumedEvent) {
log::info!("Reconnected to gateway")
tracing::info!("Reconnected to gateway")
}
async fn voice_state_update(
@ -72,10 +72,10 @@ impl EventHandler for Handler {
}
if let Some(count) = member_count {
log::debug!("{} Members in channel", count);
tracing::debug!("{} Members in channel", count);
if let Some(player) = get_music_player_for_guild(&ctx, guild_id).await {
let mut player = player.lock().await;
log::debug!("Setting leave flag to {}", count == 0);
tracing::debug!("Setting leave flag to {}", count == 0);
player.set_leave_flag(count == 0);
}
}