mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 19:19:41 +00:00
The logging system has been brought to a fully functional level.
This commit is contained in:
19
Cargo.lock
generated
19
Cargo.lock
generated
@@ -221,13 +221,12 @@ dependencies = [
|
|||||||
name = "dcr"
|
name = "dcr"
|
||||||
version = "0.9.1"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"fatfs",
|
"fatfs",
|
||||||
"glob",
|
"glob",
|
||||||
"log",
|
"log",
|
||||||
"paris-log",
|
"owo-colors",
|
||||||
"self-replace",
|
"self-replace",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -748,20 +747,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paris"
|
name = "owo-colors"
|
||||||
version = "1.5.15"
|
version = "4.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8fecab3723493c7851f292cb060f3ee1c42f19b8d749345d0d7eaf3fd19aa62d"
|
checksum = "13c45bb4a6ae1280ec0803b1ef9d3455eb50f01efbbe1447ab020f1d54fba9d8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "paris-log"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "774dbe6c00feee96462fae6b32789d9f570569f0b1543cea61336932b240d7eb"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"paris",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ fatfs = { version = "0.3", optional = true }
|
|||||||
#Logging
|
#Logging
|
||||||
log = "0.4.34"
|
log = "0.4.34"
|
||||||
env_logger = "0.11.11"
|
env_logger = "0.11.11"
|
||||||
anstyle = "1.0.14"
|
owo-colors = "4"
|
||||||
paris-log = "1" # Под влияние попадают все строки переданные в логирование, надо осторожно
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ pub fn add(args: &[String]) -> i32 {
|
|||||||
let mut config = match Config::open(&root.join("dcr.toml").to_string_lossy()) {
|
let mut config = match Config::open(&root.join("dcr.toml").to_string_lossy()) {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("{}", &err.to_string());
|
error!("{err}");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ pub fn build(args: &[String]) -> i32 {
|
|||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
common::finish_progress_line();
|
common::finish_progress_line();
|
||||||
error!("{}", &err.message);
|
error!("{}", err.message);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
use crate::utils::log;
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod config;
|
mod config;
|
||||||
mod core;
|
mod core;
|
||||||
@@ -30,7 +29,7 @@ use prelude::*;
|
|||||||
/// appropriate subcommand handler. With fewer than two arguments, shows help and
|
/// appropriate subcommand handler. With fewer than two arguments, shows help and
|
||||||
/// exits with code 0; otherwise exits with the handler's exit code.
|
/// exits with code 0; otherwise exits with the handler's exit code.
|
||||||
fn main() {
|
fn main() {
|
||||||
log::init();
|
utils::log::init();
|
||||||
|
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
pub use paris_log::{error, warn};
|
pub use log::{error, warn};
|
||||||
|
// use owo_colors::OwoColorize;
|
||||||
|
|||||||
@@ -15,34 +15,30 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use anstyle::{AnsiColor, Style};
|
|
||||||
use env_logger::*;
|
use env_logger::*;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
// Функция инициализирующая логирование
|
// Функция инициализирующая логирование
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
Builder::new()
|
Builder::new()
|
||||||
.filter_level(LevelFilter::Warn)
|
.filter_level(LevelFilter::Warn)
|
||||||
|
.write_style(WriteStyle::Auto)
|
||||||
.format(|buf, record| {
|
.format(|buf, record| {
|
||||||
let color = match record.level() {
|
let colored_lv = match record.level() {
|
||||||
Level::Error => AnsiColor::Red,
|
Level::Error => record.level().red().to_string(),
|
||||||
Level::Warn => AnsiColor::Yellow,
|
Level::Warn => record.level().yellow().to_string(),
|
||||||
Level::Info => AnsiColor::White,
|
Level::Info => record.level().default_color().to_string(),
|
||||||
Level::Debug => AnsiColor::Magenta,
|
_ => record.level().purple().italic().to_string(),
|
||||||
Level::Trace => AnsiColor::BrightBlack,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let style = Style::new().fg_color(Some(color.into())).bold();
|
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
buf,
|
buf,
|
||||||
"{style}{}{style:#}: {}",
|
"{}: {}",
|
||||||
record.level().to_string().to_lowercase(),
|
colored_lv.to_lowercase().bold(),
|
||||||
record.args(),
|
record.args(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
// env_logger::init(); // Уровень логирования из переменных окружения
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user