Skip to content

Commit

Permalink
add logging framework
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc authored Oct 30, 2023
1 parent 97a3f77 commit 38e7b4f
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 155 deletions.
179 changes: 179 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ is-terminal = "0.4"
itertools = "0.10"
json = "0.12"
lazy_static = "1.4"
log = "*"
log4rs = "1"
md5 = "0.7"
modular-bitfield = "0.11"
multipart = { features = ["server"], git = 'https://github.com/lifegpc/multipart', optional = true, default-features = false }
Expand Down
18 changes: 6 additions & 12 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,11 @@ pub async fn download_artwork_app(
) -> Result<(), PixivDownloaderError> {
let data = ac.get_illust_details(id).await?;
let helper = get_helper();
if helper.verbose() {
println!("{:#?}", data);
}
log::debug!("{:#?}", data);
match crate::pixivapp::check::CheckUnknown::check_unknown(&data) {
Ok(_) => {}
Err(e) => {
println!(
log::warn!(
"{} {}",
gettext("Warning: Post info contains unknown data:"),
e
Expand Down Expand Up @@ -834,13 +832,11 @@ pub async fn download_fanbox_post(
.await
.try_err(gettext("Failed to get post info."))?;
let helper = get_helper();
if helper.verbose() {
println!("{:#?}", post);
}
log::debug!("{:#?}", post);
match post.check_unknown() {
Ok(_) => {}
Err(e) => {
println!(
log::warn!(
"{} {}",
gettext("Warning: Post info contains unknown data:"),
e
Expand All @@ -851,7 +847,7 @@ pub async fn download_fanbox_post(
.is_restricted()
.try_err(gettext("Failed to check the post is restricted or not."))?
{
println!("{}", gettext("Warning: This article is restricted."));
log::warn!("{}", gettext("Warning: This article is restricted."));
// #TODO allow to continue
return Ok(());
}
Expand Down Expand Up @@ -1129,9 +1125,7 @@ pub async fn download_fanbox_creator_info(
};
let data = Arc::new(data);
let helper = get_helper();
if helper.verbose() {
println!("{:#?}", data);
}
log::debug!("{:#?}", data);
match data.check_unknown() {
Ok(_) => {}
Err(e) => {
Expand Down
Loading

0 comments on commit 38e7b4f

Please sign in to comment.