Move spammy command log messages to debug level

And add some info level logs that summarize each command.
This commit is contained in:
Tyler Hallada 2023-04-24 00:04:29 -04:00
parent 01444cd928
commit 694ef6e89b
7 changed files with 26 additions and 14 deletions

View File

@ -2,11 +2,12 @@ use anyhow::Result;
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use tracing::info; use tracing::{debug, info};
use crate::models::cell; use crate::models::cell;
pub async fn dump_cell_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Result<()> { pub async fn dump_cell_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Result<()> {
let mut cell_count = 0;
for x in -77..75 { for x in -77..75 {
for y in -50..44 { for y in -50..44 {
if let Ok(data) = cell::get_cell_data(pool, "Skyrim.esm", 1, x, y).await { if let Ok(data) = cell::get_cell_data(pool, "Skyrim.esm", 1, x, y).await {
@ -14,7 +15,7 @@ pub async fn dump_cell_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Res
let path = Path::new(&path); let path = Path::new(&path);
create_dir_all(path)?; create_dir_all(path)?;
let path = path.join(format!("{}.json", y)); let path = path.join(format!("{}.json", y));
info!( debug!(
x = x, x = x,
y = y, y = y,
form_id = data.form_id, form_id = data.form_id,
@ -23,8 +24,10 @@ pub async fn dump_cell_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Res
); );
let mut file = File::create(path)?; let mut file = File::create(path)?;
write!(file, "{}", serde_json::to_string(&data)?)?; write!(file, "{}", serde_json::to_string(&data)?)?;
cell_count += 1;
} }
} }
} }
info!("dumped {} cell data files", cell_count);
Ok(()) Ok(())
} }

View File

@ -2,7 +2,7 @@ use anyhow::Result;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use tracing::info; use tracing::{debug, info};
use crate::models::cell; use crate::models::cell;
@ -11,7 +11,7 @@ pub async fn dump_cell_edit_counts(pool: &sqlx::Pool<sqlx::Postgres>, path: &str
for x in -77..75 { for x in -77..75 {
for y in -50..44 { for y in -50..44 {
if let Some(count) = cell::count_mod_edits(pool, "Skyrim.esm", 1, x, y).await? { if let Some(count) = cell::count_mod_edits(pool, "Skyrim.esm", 1, x, y).await? {
info!(x = x, y = y, count = count, "read cell edit count"); debug!(x = x, y = y, count = count, "read cell edit count");
cell_mod_edit_counts.insert(format!("{},{}", x, y), count); cell_mod_edit_counts.insert(format!("{},{}", x, y), count);
} }
} }

View File

@ -3,7 +3,7 @@ use chrono::NaiveDateTime;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use tracing::info; use tracing::{debug, info};
use crate::models::file; use crate::models::file;
@ -12,6 +12,7 @@ pub async fn dump_file_data(
dir: &str, dir: &str,
updated_after: Option<NaiveDateTime>, updated_after: Option<NaiveDateTime>,
) -> Result<()> { ) -> Result<()> {
let mut file_count = 0;
let mut page = 1; let mut page = 1;
let page_size = 20; let page_size = 20;
let mut last_id = None; let mut last_id = None;
@ -26,7 +27,7 @@ pub async fn dump_file_data(
let path = Path::new(&dir); let path = Path::new(&dir);
std::fs::create_dir_all(path)?; std::fs::create_dir_all(path)?;
let path = path.join(format!("{}.json", file_with_cells.nexus_file_id)); let path = path.join(format!("{}.json", file_with_cells.nexus_file_id));
info!( debug!(
page = page, page = page,
nexus_file_id = file_with_cells.nexus_file_id, nexus_file_id = file_with_cells.nexus_file_id,
"dumping file data to {}", "dumping file data to {}",
@ -35,8 +36,10 @@ pub async fn dump_file_data(
let mut file = File::create(path)?; let mut file = File::create(path)?;
write!(file, "{}", serde_json::to_string(&file_with_cells)?)?; write!(file, "{}", serde_json::to_string(&file_with_cells)?)?;
last_id = Some(file_with_cells.id); last_id = Some(file_with_cells.id);
file_count += 1;
} }
page += 1; page += 1;
} }
info!("dumped {} file data files", file_count);
Ok(()) Ok(())
} }

View File

@ -2,7 +2,7 @@ use anyhow::Result;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use tracing::info; use tracing::{debug, info};
use crate::models::game_mod; use crate::models::game_mod;
@ -18,7 +18,7 @@ pub async fn dump_mod_cell_counts(pool: &sqlx::Pool<sqlx::Postgres>, path: &str)
break; break;
} }
for mod_cell_count in mod_cell_counts { for mod_cell_count in mod_cell_counts {
info!( debug!(
page = page, page = page,
nexus_mod_id = mod_cell_count.nexus_mod_id, nexus_mod_id = mod_cell_count.nexus_mod_id,
count = mod_cell_count.cells.unwrap_or(0), count = mod_cell_count.cells.unwrap_or(0),

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use tracing::info; use tracing::{debug, info};
use crate::models::game; use crate::models::game;
use crate::models::game_mod; use crate::models::game_mod;
@ -14,6 +14,7 @@ pub async fn dump_mod_data(
dir: &str, dir: &str,
updated_after: Option<NaiveDateTime>, updated_after: Option<NaiveDateTime>,
) -> Result<()> { ) -> Result<()> {
let mut mod_count = 0;
let mut page = 1; let mut page = 1;
let page_size = 20; let page_size = 20;
let mut last_id = None; let mut last_id = None;
@ -43,7 +44,7 @@ pub async fn dump_mod_data(
); );
std::fs::create_dir_all(&path)?; std::fs::create_dir_all(&path)?;
let path = path.join(format!("{}.json", mod_with_cells.nexus_mod_id)); let path = path.join(format!("{}.json", mod_with_cells.nexus_mod_id));
info!( debug!(
page = page, page = page,
nexus_mod_id = mod_with_cells.nexus_mod_id, nexus_mod_id = mod_with_cells.nexus_mod_id,
"dumping mod data to {}", "dumping mod data to {}",
@ -52,8 +53,10 @@ pub async fn dump_mod_data(
let mut file = File::create(path)?; let mut file = File::create(path)?;
write!(file, "{}", serde_json::to_string(&mod_with_cells)?)?; write!(file, "{}", serde_json::to_string(&mod_with_cells)?)?;
last_id = Some(mod_with_cells.id); last_id = Some(mod_with_cells.id);
mod_count += 1;
} }
page += 1; page += 1;
} }
info!("dumped {} mod data files", mod_count);
Ok(()) Ok(())
} }

View File

@ -2,7 +2,7 @@ use anyhow::Result;
use serde::Serialize; use serde::Serialize;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use tracing::info; use tracing::{debug, info};
use crate::models::game; use crate::models::game;
use crate::models::game_mod; use crate::models::game_mod;
@ -29,7 +29,7 @@ pub async fn dump_mod_search_index(
break; break;
} }
for mod_for_search in mods { for mod_for_search in mods {
info!( debug!(
page = page, page = page,
nexus_mod_id = mod_for_search.nexus_mod_id, nexus_mod_id = mod_for_search.nexus_mod_id,
"read mod name for search index" "read mod name for search index"

View File

@ -3,7 +3,7 @@ use chrono::NaiveDateTime;
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use tracing::info; use tracing::{debug, info};
use crate::models::{format_radix, plugin}; use crate::models::{format_radix, plugin};
@ -12,6 +12,7 @@ pub async fn dump_plugin_data(
dir: &str, dir: &str,
updated_after: Option<NaiveDateTime>, updated_after: Option<NaiveDateTime>,
) -> Result<()> { ) -> Result<()> {
let mut plugin_count = 0;
let mut page: u32 = 1; let mut page: u32 = 1;
let page_size = 20; let page_size = 20;
let mut last_hash = None; let mut last_hash = None;
@ -32,7 +33,7 @@ pub async fn dump_plugin_data(
let path = Path::new(&dir); let path = Path::new(&dir);
create_dir_all(path)?; create_dir_all(path)?;
let path = path.join(format!("{}.json", format_radix(plugin.hash as u64, 36))); let path = path.join(format!("{}.json", format_radix(plugin.hash as u64, 36)));
info!( debug!(
page = page, page = page,
hash = plugin.hash, hash = plugin.hash,
"dumping plugin data to {}", "dumping plugin data to {}",
@ -42,8 +43,10 @@ pub async fn dump_plugin_data(
let json_val = serde_json::to_string(&plugin)?; let json_val = serde_json::to_string(&plugin)?;
write!(file, "{}", json_val)?; write!(file, "{}", json_val)?;
last_hash = Some(plugin.hash); last_hash = Some(plugin.hash);
plugin_count += 1;
} }
page += 1; page += 1;
} }
info!("dumped {} plugin data files", plugin_count);
Ok(()) Ok(())
} }