fix: release builds not logging

This commit is contained in:
Lucaskyy 2022-07-09 17:51:52 +02:00
parent cee17a11eb
commit d69ae966c5
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89
3 changed files with 12 additions and 8 deletions

View File

@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] }
dotenv = "0.15" dotenv = "0.15"
serde_json = "1.0" serde_json = "1.0"
tokio = { version = "1.0", features = ["rt-multi-thread"] } tokio = { version = "1.0", features = ["rt-multi-thread"] }
log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] } log = { version = "0.4", features = ["max_level_debug"] }
regex = "1.0" regex = "1.0"
serde_regex = "1.1" serde_regex = "1.1"
chrono = "0.4" chrono = "0.4"

View File

@ -11,7 +11,11 @@ pub fn init() -> anyhow::Result<()> {
TerminalMode::Mixed, TerminalMode::Mixed,
ColorChoice::Auto, ColorChoice::Auto,
), ),
WriteLogger::new(LevelFilter::Info, Config::default(), File::create("logs.log")?), WriteLogger::new(
LevelFilter::Info,
Config::default(),
File::create("logs.log")?
),
])?; ])?;
Ok(()) Ok(())

View File

@ -2,7 +2,7 @@ use std::sync::Arc;
use std::{env, process}; use std::{env, process};
use chrono::{DateTime, Duration, NaiveDateTime, Utc}; use chrono::{DateTime, Duration, NaiveDateTime, Utc};
use log::{error, info, trace}; use log::{error, info, debug};
use model::application::Configuration; use model::application::Configuration;
use regex::Regex; use regex::Regex;
use serenity::client::{Context, EventHandler}; use serenity::client::{Context, EventHandler};
@ -44,7 +44,7 @@ fn load_configuration() -> Configuration {
#[async_trait] #[async_trait]
impl EventHandler for Handler { impl EventHandler for Handler {
async fn interaction_create(&self, ctx: Context, interaction: Interaction) { async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
trace!("Created an interaction: {:?}", interaction); debug!("Created an interaction: {:?}", interaction);
if let Interaction::ApplicationCommand(command) = interaction { if let Interaction::ApplicationCommand(command) = interaction {
let configuration_lock = get_configuration_lock(&ctx).await; let configuration_lock = get_configuration_lock(&ctx).await;
@ -73,7 +73,7 @@ impl EventHandler for Handler {
let content = if permission_granted { let content = if permission_granted {
match command.data.name.as_str() { match command.data.name.as_str() {
"reload" => { "reload" => {
trace!("{:?} reloaded the configuration.", command.user); debug!("{:?} reloaded the configuration.", command.user);
let new_config = load_configuration(); let new_config = load_configuration();
@ -84,7 +84,7 @@ impl EventHandler for Handler {
"Successfully reloaded configuration.".to_string() "Successfully reloaded configuration.".to_string()
}, },
"stop" => { "stop" => {
trace!("{:?} stopped the bot.", command.user); debug!("{:?} stopped the bot.", command.user);
stop_command = true; stop_command = true;
"Stopped the bot.".to_string() "Stopped the bot.".to_string()
}, },
@ -115,7 +115,7 @@ impl EventHandler for Handler {
} }
async fn message(&self, ctx: Context, msg: Message) { async fn message(&self, ctx: Context, msg: Message) {
trace!("Received message: {}", msg.content); debug!("Received message: {}", msg.content);
if msg.guild_id.is_none() || msg.author.bot { if msg.guild_id.is_none() || msg.author.bot {
return; return;
} }
@ -185,7 +185,7 @@ impl EventHandler for Handler {
async fn thread_create(&self, ctx: Context, thread: GuildChannel) { async fn thread_create(&self, ctx: Context, thread: GuildChannel) {
if thread.member.is_some() { if thread.member.is_some() {
trace!("Thread was joined. Block dispatch."); debug!("Thread was joined. Block dispatch.");
return; return;
} }