mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-24 06:34:09 +00:00
Update logging and enhance .gitignore for Atlas directory
- Introduced a logging system using `tracing` and related crates to improve log management and output formatting. - Updated `.gitignore` to include the `.atlas/` directory, ensuring that log files and other generated content are not tracked by Git. - Enhanced project templates to include the new `.gitignore` settings for Atlas in various project types. These changes aim to improve logging capabilities and maintain a cleaner repository by ignoring unnecessary files.
This commit is contained in:
parent
b5583c4c1b
commit
3fd50df0b2
29 changed files with 1463 additions and 79 deletions
36
src/main.rs
36
src/main.rs
|
|
@ -3,15 +3,14 @@ use std::{env, panic, process};
|
|||
use backtrace::Backtrace;
|
||||
use clap::Parser;
|
||||
|
||||
use librojo::cli::Options;
|
||||
use librojo::cli::{resolve_project_dir, Options};
|
||||
use librojo::logging;
|
||||
|
||||
fn main() {
|
||||
#[cfg(feature = "profile-with-tracy")]
|
||||
profiling::tracy_client::Client::start();
|
||||
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
// PanicInfo's payload is usually a &'static str or String.
|
||||
// See: https://doc.rust-lang.org/beta/std/panic/struct.PanicInfo.html#method.payload
|
||||
let message = match panic_info.payload().downcast_ref::<&str>() {
|
||||
Some(&message) => message.to_string(),
|
||||
None => match panic_info.payload().downcast_ref::<String>() {
|
||||
|
|
@ -37,9 +36,6 @@ fn main() {
|
|||
log::error!("in file {} on line {}", location.file(), location.line());
|
||||
}
|
||||
|
||||
// When using the backtrace crate, we need to check the RUST_BACKTRACE
|
||||
// environment variable ourselves. Once we switch to the (currently
|
||||
// unstable) std::backtrace module, we won't need to do this anymore.
|
||||
let should_backtrace = env::var("RUST_BACKTRACE")
|
||||
.map(|var| var == "1")
|
||||
.unwrap_or(false);
|
||||
|
|
@ -57,22 +53,22 @@ fn main() {
|
|||
|
||||
let options = Options::parse();
|
||||
|
||||
let log_filter = match options.global.verbosity {
|
||||
0 => "info",
|
||||
1 => "info,librojo=debug",
|
||||
2 => "info,librojo=trace",
|
||||
_ => "trace",
|
||||
};
|
||||
let project_dir = options.subcommand.project_path().map(resolve_project_dir);
|
||||
|
||||
let log_env = env_logger::Env::default().default_filter_or(log_filter);
|
||||
let file_log_level = project_dir
|
||||
.as_deref()
|
||||
.and_then(logging::quick_read_file_log_level)
|
||||
.unwrap_or(Some(tracing::level_filters::LevelFilter::TRACE));
|
||||
|
||||
env_logger::Builder::from_env(log_env)
|
||||
.format_module_path(false)
|
||||
.format_timestamp(None)
|
||||
// Indent following lines equal to the log level label, like `[ERROR] `
|
||||
.format_indent(Some(8))
|
||||
.write_style(options.global.color.into())
|
||||
.init();
|
||||
let command_name = format!("atlas-{}", options.subcommand.command_name());
|
||||
|
||||
let _log_guard = logging::init_logging(
|
||||
options.global.verbosity,
|
||||
options.global.color,
|
||||
project_dir.as_deref(),
|
||||
file_log_level,
|
||||
&command_name,
|
||||
);
|
||||
|
||||
if let Err(err) = options.run() {
|
||||
log::error!("{:?}", err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue