diff --git a/fvwm/modconf.c b/fvwm/modconf.c index bb466fefe..b2065b304 100644 --- a/fvwm/modconf.c +++ b/fvwm/modconf.c @@ -49,6 +49,7 @@ #include "module_interface.h" #include "colorset.h" #include "libs/FScreen.h" +#include "libs/log.h" #include "expand.h" extern int nColorsets; /* in libs/Colorset.c */ @@ -365,6 +366,15 @@ void send_ignore_modifiers(fmodule *module) return; } +void +send_logging_fd(fmodule *module) +{ + char msg[64]; + + snprintf(msg, sizeof(msg), "LoggingFD %d\n", log_get_fd()); + SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); +} + void send_monitor_list(fmodule *module) { BroadcastMonitorList(module); @@ -387,6 +397,7 @@ void CMD_Send_ConfigInfo(F_CMD_ARGS) send_click_time(mod); send_move_threshold(mod); send_desktop_geometry(mod); + send_logging_fd(mod); match = PeekToken(action, &action); if (match) { diff --git a/libs/log.c b/libs/log.c index 718ba70bb..bf40963c4 100644 --- a/libs/log.c +++ b/libs/log.c @@ -36,6 +36,24 @@ static char *log_file_name; static FILE *log_file; int lib_log_level = 0; +int +log_get_fd(void) +{ + if (log_file == NULL) + return -1; + return fileno(log_file); +} + +void +log_set_fd(int fd) +{ + if (fd == -1) + return; + + /* This is enough to allow modules to be able to log. */ + log_file = fdopen(fd, "a"); +} + void set_log_file(char *name) { diff --git a/libs/log.h b/libs/log.h index 93753105c..d0247cbeb 100644 --- a/libs/log.h +++ b/libs/log.h @@ -9,6 +9,8 @@ void set_log_file(char *name); void log_open(const char *); void log_toggle(const char *); void log_close(void); +int log_get_fd(void); +void log_set_fd(int); void printflike(2, 3) fvwm_debug(const char *, const char *, ...); #endif