You've already forked AstralRinth
forked from didirus/AstralRinth
0.8.0 beta fixes (#2154)
* initial fixes * 0.8.0 beta fixes * run actions * run fmt * Fix windows build * Add purge cache opt * add must revalidate to project req * lint + clippy * fix processes, open folder * Update migrator to use old launcher cache for perf * fix empty dirs not moving * fix lint + create natives dir if not exist * fix large request batches * finish * Fix deep linking on mac * fix comp err * fix comp err (2) --------- Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -15,12 +15,10 @@
|
||||
|
||||
*/
|
||||
|
||||
use tracing_appender::non_blocking::WorkerGuard;
|
||||
|
||||
// Handling for the live development logging
|
||||
// This will log to the console, and will not log to a file
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn start_logger() -> Option<WorkerGuard> {
|
||||
pub fn start_logger() -> Option<()> {
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
||||
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
@@ -33,15 +31,16 @@ pub fn start_logger() -> Option<WorkerGuard> {
|
||||
.with(tracing_error::ErrorLayer::default());
|
||||
tracing::subscriber::set_global_default(subscriber)
|
||||
.expect("setting default subscriber failed");
|
||||
None
|
||||
Some(())
|
||||
}
|
||||
|
||||
// Handling for the live production logging
|
||||
// This will log to a file in the logs directory, and will not show any logs in the console
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub fn start_logger() -> Option<WorkerGuard> {
|
||||
pub fn start_logger() -> Option<()> {
|
||||
use crate::prelude::DirectoryInfo;
|
||||
use tracing_appender::rolling::{RollingFileAppender, Rotation};
|
||||
use chrono::Local;
|
||||
use std::fs::OpenOptions;
|
||||
use tracing_subscriber::fmt::time::ChronoLocal;
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
||||
@@ -53,17 +52,34 @@ pub fn start_logger() -> Option<WorkerGuard> {
|
||||
return None;
|
||||
};
|
||||
|
||||
let log_file_name =
|
||||
format!("session_{}.log", Local::now().format("%Y%m%d_%H%M%S"));
|
||||
let log_file_path = logs_dir.join(log_file_name);
|
||||
|
||||
if let Err(err) = std::fs::create_dir_all(&logs_dir) {
|
||||
eprintln!("Could not create logs directory: {err}");
|
||||
}
|
||||
|
||||
let file = match OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(true)
|
||||
.open(&log_file_path)
|
||||
{
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
eprintln!("Could not start open log file: {e}");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("theseus=info"));
|
||||
|
||||
let file_appender =
|
||||
RollingFileAppender::new(Rotation::DAILY, logs_dir, "theseus.log");
|
||||
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
|
||||
|
||||
let subscriber = tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::fmt::layer()
|
||||
.with_writer(non_blocking)
|
||||
.with_writer(file)
|
||||
.with_ansi(false) // disable ANSI escape codes
|
||||
.with_timer(ChronoLocal::rfc_3339()),
|
||||
)
|
||||
@@ -73,5 +89,5 @@ pub fn start_logger() -> Option<WorkerGuard> {
|
||||
tracing::subscriber::set_global_default(subscriber)
|
||||
.expect("Setting default subscriber failed");
|
||||
|
||||
Some(guard)
|
||||
Some(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user