Restore logpath for deployment. Resolve warning from copy() not having err handled.

This commit is contained in:
Derek J. Clark 2022-11-28 15:04:49 -08:00
parent 96bfff0131
commit 1fa7009ce1
3 changed files with 14 additions and 6 deletions

4
backend/Cargo.lock generated
View file

@ -1077,9 +1077,9 @@ dependencies = [
[[package]]
name = "usdpl-back"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88709aa9d6c5c65c0e8715dbb716b253ceebd0bd1097c4e5316660320ae604e1"
checksum = "58928ed65332c30b9b9be5140fcdab97e45db679a5845d829aa26492765272e5"
dependencies = [
"async-recursion",
"async-trait",

View file

@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
usdpl-back = { version = "0.7.1", features = ["blocking"]}
usdpl-back = { version = "0.7.2", features = ["blocking"]}
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View file

@ -23,12 +23,19 @@ fn main() -> Result<(), ()> {
let log_filepath = usdpl_back::api::dirs::home()
.unwrap_or_else(|| "/tmp/".into())
.join(PACKAGE_NAME.to_owned()+".log");
println!("Found home dir: {:?}", log_filepath);
#[cfg(not(debug_assertions))]
let log_filepath = std::path::PathBuf.new("/tmp/"+PACKAGE_NAME.to_owned()+".log");
#[cfg(debug_assertions)]
let old_log_filepath = usdpl_back::api::dirs::home()
.unwrap_or_else(|| "/tmp/".into())
.join(PACKAGE_NAME.to_owned()+".log.old");
#[cfg(debug_assertions)]
{
if std::path::Path::new(&log_filepath).exists() {
std::fs::copy(&log_filepath, &log_filepath.join(".old"));
std::fs::copy(&log_filepath, &old_log_filepath).expect("Unable to increment logs. Do you have write permissions?");
}
}
#[cfg(debug_assertions)]
WriteLogger::init(
#[cfg(debug_assertions)]
{
@ -42,7 +49,8 @@ fn main() -> Result<(), ()> {
std::fs::File::create(&log_filepath).unwrap(),
)
.unwrap();
log::debug!("Loggin started at {:?}.", log_filepath);
log::debug!("Logging to: {:?}.", log_filepath);
println!("Logging to: {:?}", log_filepath);
log::info!("Starting back-end ({} v{})", PACKAGE_NAME, PACKAGE_VERSION);
println!("Starting back-end ({} v{})", PACKAGE_NAME, PACKAGE_VERSION);