From 98282c5a420ccc45be9d8de939fe6ea38fc779d6 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Tue, 10 Jan 2023 19:33:45 +0100 Subject: [PATCH] truncate log file at every start --- src/lib.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f7f1c91..c436657 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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())