Add tracing logging to all commands
This commit is contained in:
parent
8f420c5558
commit
bafa405223
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,5 @@ plugins.zip
|
|||||||
plugins
|
plugins
|
||||||
cells
|
cells
|
||||||
mods
|
mods
|
||||||
|
plugins_data
|
||||||
files
|
files
|
@ -3,6 +3,7 @@ use reqwest::Client;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
pub async fn download_tiles(dir: &str) -> Result<()> {
|
pub async fn download_tiles(dir: &str) -> Result<()> {
|
||||||
let client = Client::builder().build()?;
|
let client = Client::builder().build()?;
|
||||||
@ -18,7 +19,7 @@ pub async fn download_tiles(dir: &str) -> Result<()> {
|
|||||||
);
|
);
|
||||||
let resp = client.get(&url).send().await?;
|
let resp = client.get(&url).send().await?;
|
||||||
if resp.status().is_success() {
|
if resp.status().is_success() {
|
||||||
println!("{}", url);
|
info!(z = z, x = x, y = y, "fetched tile from {}", url);
|
||||||
std::fs::create_dir_all(format!("{}/{z}/{x}", dir, z = z, x = x))?;
|
std::fs::create_dir_all(format!("{}/{z}/{x}", dir, z = z, x = x))?;
|
||||||
let mut out =
|
let mut out =
|
||||||
File::create(format!("{}/{z}/{x}/{y}.jpg", dir, z = z, x = x, y = y))?;
|
File::create(format!("{}/{z}/{x}/{y}.jpg", dir, z = z, x = x, y = y))?;
|
||||||
|
@ -2,6 +2,7 @@ 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 crate::models::cell;
|
use crate::models::cell;
|
||||||
|
|
||||||
@ -13,6 +14,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!(x = x, y = y, form_id = data.form_id, "dumping cell data to {}", path.display());
|
||||||
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)?)?;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +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 crate::models::cell;
|
use crate::models::cell;
|
||||||
|
|
||||||
@ -10,10 +11,12 @@ 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");
|
||||||
cell_mod_edit_counts.insert(format!("{},{}", x, y), count);
|
cell_mod_edit_counts.insert(format!("{},{}", x, y), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
info!("writing {} cell edit counts to {}", cell_mod_edit_counts.len(), path);
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
write!(file, "{}", serde_json::to_string(&cell_mod_edit_counts)?)?;
|
write!(file, "{}", serde_json::to_string(&cell_mod_edit_counts)?)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -3,10 +3,12 @@ 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 crate::models::file;
|
use crate::models::file;
|
||||||
|
|
||||||
pub async fn dump_file_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
pub async fn dump_file_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||||
|
let mut page = 1;
|
||||||
let page_size = 20;
|
let page_size = 20;
|
||||||
let mut last_id = None;
|
let mut last_id = None;
|
||||||
loop {
|
loop {
|
||||||
@ -19,10 +21,12 @@ pub async fn dump_file_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, update
|
|||||||
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!(page = page, nexus_file_id = file_with_cells.nexus_file_id, "dumping file data to {}", path.display());
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
page += 1;
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ 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 crate::models::game_mod;
|
use crate::models::game_mod;
|
||||||
|
|
||||||
pub async fn dump_mod_cell_counts(pool: &sqlx::Pool<sqlx::Postgres>, path: &str) -> Result<()> {
|
pub async fn dump_mod_cell_counts(pool: &sqlx::Pool<sqlx::Postgres>, path: &str) -> Result<()> {
|
||||||
|
let mut page = 1;
|
||||||
let page_size = 100;
|
let page_size = 100;
|
||||||
let mut last_id = None;
|
let mut last_id = None;
|
||||||
let mut counts = HashMap::new();
|
let mut counts = HashMap::new();
|
||||||
@ -16,10 +18,13 @@ 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!(page = page, nexus_mod_id = mod_cell_count.nexus_mod_id, count = mod_cell_count.cells.unwrap_or(0), "read mod cell count");
|
||||||
counts.insert(mod_cell_count.nexus_mod_id, mod_cell_count.cells);
|
counts.insert(mod_cell_count.nexus_mod_id, mod_cell_count.cells);
|
||||||
last_id = Some(mod_cell_count.nexus_mod_id);
|
last_id = Some(mod_cell_count.nexus_mod_id);
|
||||||
}
|
}
|
||||||
|
page += 1;
|
||||||
}
|
}
|
||||||
|
info!("writing {} mod cell counts to {}", counts.len(), path);
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
write!(file, "{}", serde_json::to_string(&counts)?)?;
|
write!(file, "{}", serde_json::to_string(&counts)?)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -3,10 +3,12 @@ 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 crate::models::game_mod;
|
use crate::models::game_mod;
|
||||||
|
|
||||||
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||||
|
let mut page = 1;
|
||||||
let page_size = 20;
|
let page_size = 20;
|
||||||
let mut last_id = None;
|
let mut last_id = None;
|
||||||
loop {
|
loop {
|
||||||
@ -19,10 +21,12 @@ pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated
|
|||||||
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", mod_with_cells.nexus_mod_id));
|
let path = path.join(format!("{}.json", mod_with_cells.nexus_mod_id));
|
||||||
|
info!(page = page, nexus_mod_id = mod_with_cells.nexus_mod_id, "dumping mod data to {}", path.display());
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
page += 1;
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +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 crate::models::game_mod;
|
use crate::models::game_mod;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ struct ModForSearchIdTranslated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn dump_mod_search_index(pool: &sqlx::Pool<sqlx::Postgres>, path: &str) -> Result<()> {
|
pub async fn dump_mod_search_index(pool: &sqlx::Pool<sqlx::Postgres>, path: &str) -> Result<()> {
|
||||||
|
let mut page = 1;
|
||||||
let mut search_index = vec![];
|
let mut search_index = vec![];
|
||||||
let page_size = 20;
|
let page_size = 20;
|
||||||
let mut last_id = None;
|
let mut last_id = None;
|
||||||
@ -21,13 +23,16 @@ pub async fn dump_mod_search_index(pool: &sqlx::Pool<sqlx::Postgres>, path: &str
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for mod_for_search in mods {
|
for mod_for_search in mods {
|
||||||
|
info!(page = page, nexus_mod_id = mod_for_search.nexus_mod_id, "read mod name for search index");
|
||||||
search_index.push(ModForSearchIdTranslated {
|
search_index.push(ModForSearchIdTranslated {
|
||||||
name: mod_for_search.name,
|
name: mod_for_search.name,
|
||||||
id: mod_for_search.nexus_mod_id,
|
id: mod_for_search.nexus_mod_id,
|
||||||
});
|
});
|
||||||
last_id = Some(mod_for_search.id);
|
last_id = Some(mod_for_search.id);
|
||||||
}
|
}
|
||||||
|
page += 1;
|
||||||
}
|
}
|
||||||
|
info!("writing {} mod names for search index to {}", search_index.len(), path);
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
write!(file, "{}", serde_json::to_string(&search_index)?)?;
|
write!(file, "{}", serde_json::to_string(&search_index)?)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -3,6 +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 crate::models::plugin;
|
use crate::models::plugin;
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ fn format_radix(mut x: u64, radix: u32) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn dump_plugin_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
pub async fn dump_plugin_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||||
|
let mut page: u32 = 1;
|
||||||
let page_size = 20;
|
let page_size = 20;
|
||||||
let mut last_hash = None;
|
let mut last_hash = None;
|
||||||
loop {
|
loop {
|
||||||
@ -35,10 +37,12 @@ pub async fn dump_plugin_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, upda
|
|||||||
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!(page = page, hash = plugin.hash, "dumping plugin data to {}", path.display());
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
write!(file, "{}", serde_json::to_string(&plugin)?)?;
|
write!(file, "{}", serde_json::to_string(&plugin)?)?;
|
||||||
last_hash = Some(plugin.hash);
|
last_hash = Some(plugin.hash);
|
||||||
}
|
}
|
||||||
|
page += 1;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user