truncate log file at every start

This commit is contained in:
hodasemi 2023-01-10 19:33:45 +01:00
parent 062a5f9ce9
commit 98282c5a42

View file

@ -7,7 +7,13 @@ mod instance_handles;
#[macro_use]
mod device_handles;
use std::{fs::OpenOptions, io::Write, mem, os::raw::c_char, ptr};
use std::{
fs::{File, OpenOptions},
io::Write,
mem,
os::raw::c_char,
ptr,
};
use device_handles::*;
use enums::*;
@ -15,11 +21,15 @@ use instance_handles::*;
use structs::*;
use vulkan_sys::prelude::*;
const LOG_FILE: &'static str = "/home/michael/rf2_vk_hud.log";
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn vkNegotiateLoaderLayerInterfaceVersion(
pVersionStruct: *mut VkNegotiateLayerInterface,
) -> VkResult {
File::create(LOG_FILE).unwrap();
write_log("======================================================");
write_log("================= New Negotiation ====================");
write_log("======================================================");
@ -43,8 +53,6 @@ extern "system" fn get_device_proc_addr(
_device: VkDevice,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log("-> vulkan layer device proc addr");
get_function(function_name)
}
@ -53,8 +61,6 @@ extern "system" fn get_instance_proc_addr(
_instance: VkInstance,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log("-> vulkan layer instance proc addr");
get_function(function_name)
}
@ -370,7 +376,7 @@ fn write_log(msg: impl ToString) {
let mut file = OpenOptions::new()
.append(true)
.create(true)
.open("/home/michael/rf2_vk_hud.log")
.open(LOG_FILE)
.unwrap();
file.write_all(format!("{}\n", msg.to_string()).as_bytes())