forked from BynBang/OpenPrestige
Rename the injector and package it with an embedded payload for Windows, Linux, and macOS x64/ARM64. Add a core-only ImGui native build, multi-platform CI and release packaging, and shared per-user storage with legacy config migration.
26 lines
779 B
Rust
26 lines
779 B
Rust
use std::fs::OpenOptions;
|
|
use std::io::Write;
|
|
use std::path::PathBuf;
|
|
use std::sync::OnceLock;
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
|
fn log_path() -> &'static PathBuf {
|
|
static PATH: OnceLock<PathBuf> = OnceLock::new();
|
|
PATH.get_or_init(|| crate::paths::native_log(std::process::id()))
|
|
}
|
|
|
|
pub fn log(message: &str) {
|
|
let secs = SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
|
|
if let Some(parent) = log_path().parent() {
|
|
let _ = std::fs::create_dir_all(parent);
|
|
}
|
|
if let Ok(mut file) = OpenOptions::new().create(true).append(true).open(log_path()) {
|
|
let _ = writeln!(file, "[{secs}] {message}");
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! log {
|
|
($($arg:tt)*) => { $crate::log::log(&format!($($arg)*)) };
|
|
}
|