diff --git a/bin/MangoHud.conf b/bin/MangoHud.conf index 6248c3d1..c6cc0fdf 100644 --- a/bin/MangoHud.conf +++ b/bin/MangoHud.conf @@ -145,7 +145,8 @@ background_alpha=0.5 #upload_log=Shift+F3 ################## LOG ################# - +### Automatically start the log after X seconds +# autostart_log = 1 ### Set amount of time in second that the logging will run for # log_duration ### Define name and location of the output file (Required for logging) diff --git a/src/logging.cpp b/src/logging.cpp index 4a2a56ac..f2c4271c 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -165,4 +165,9 @@ void Logger::upload_last_log() { void Logger::upload_last_logs() { if(m_log_files.empty()) return; std::thread(upload_files, m_log_files).detach(); +} + +void autostart_log(int sleep) { + os_time_sleep(sleep * 1000000); + logger->start_logging(); } \ No newline at end of file diff --git a/src/logging.h b/src/logging.h index a7397b94..ae16603f 100644 --- a/src/logging.h +++ b/src/logging.h @@ -74,5 +74,6 @@ extern uint64_t frametime; extern logData currentLogData; string exec(string command); +void autostart_log(int sleep); #endif //MANGOHUD_LOGGING_H diff --git a/src/overlay.cpp b/src/overlay.cpp index 8e1c6806..cea2daa2 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -70,7 +70,6 @@ void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& par } void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID){ - if(not logger) logger = std::make_unique(¶ms); uint32_t f_idx = sw_stats.n_frames % ARRAY_SIZE(sw_stats.frames_stats); uint64_t now = os_time_get(); /* us */ double elapsed = (double)(now - sw_stats.last_fps_update); /* us */ diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 1eff9cc7..b390556f 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -22,7 +22,6 @@ #include "config.h" #include "string_utils.h" #include "hud_elements.h" - #include "mesa/util/os_socket.h" #ifdef HAVE_X11 @@ -380,6 +379,7 @@ parse_font_glyph_ranges(const char *str) #define parse_no_small_font(s) parse_unsigned(s) != 0 #define parse_cellpadding_y(s) parse_float(s) #define parse_table_columns(s) parse_unsigned(s) +#define parse_autostart_log(s) parse_unsigned(s) #define parse_cpu_color(s) parse_color(s) #define parse_gpu_color(s) parse_color(s) @@ -736,4 +736,8 @@ parse_overlay_config(struct overlay_params *params, // Needs ImGui context but it is null here for OpenGL so just note it and update somewhere else HUDElements.colors.update = true; + + if(not logger) logger = std::make_unique(params); + if(params->autostart_log) + std::thread(autostart_log, params->autostart_log).detach(); } diff --git a/src/overlay_params.h b/src/overlay_params.h index b3f34d22..521d30bf 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -118,6 +118,7 @@ typedef unsigned long KeySym; OVERLAY_PARAM_CUSTOM(cellpadding_y) \ OVERLAY_PARAM_CUSTOM(table_columns) \ OVERLAY_PARAM_CUSTOM(blacklist) \ + OVERLAY_PARAM_CUSTOM(autostart_log) \ enum overlay_param_position { LAYER_POSITION_TOP_LEFT, @@ -200,7 +201,7 @@ struct overlay_params { std::string cpu_text, gpu_text; //std::string blacklist; std::vector blacklist; - unsigned log_interval; + unsigned log_interval, autostart_log; std::vector media_player_order; std::vector benchmark_percentiles; std::string font_file, font_file_text;