Fix file logging on Windows.

Closes #1880. Thanks to J1EXA, richl, and EnneiteZer.
pull/1811/head
Roger A. Light 5 years ago
parent 29830ef6f1
commit 2a2cb0310b

@ -3,6 +3,7 @@ Broker:
- Fix listener not being reassociated with client when reloading a persistence
file and `per_listener_settings true` is set and the client did not set a
username. Closes #1891.
- Fix file logging on Windows. Closes #1880.
1.6.12 - 2020-08-19

@ -39,6 +39,8 @@ extern struct mosquitto_db int_db;
HANDLE syslog_h;
#endif
static char log_fptr_buffer[BUFSIZ];
/* Options for logging should be:
*
* A combination of:
@ -135,7 +137,7 @@ int log__init(struct mosquitto__config *config)
}
config->log_fptr = mosquitto__fopen(config->log_file, "at", true);
if(config->log_fptr){
setvbuf(config->log_fptr, NULL, _IOLBF, 0);
setvbuf(config->log_fptr, log_fptr_buffer, _IOLBF, sizeof(log_fptr_buffer));
}else{
log_destinations = MQTT3_LOG_STDERR;
log_priorities = MOSQ_LOG_ERR;
@ -345,6 +347,10 @@ int log__vprintf(int priority, const char *fmt, va_list va)
}else{
fprintf(log_fptr, "%s\n", s);
}
#ifdef WIN32
/* Windows does support line buffering, so flush. */
fflush(log_fptr);
#endif
}
if(log_destinations & MQTT3_LOG_SYSLOG){
#ifndef WIN32

Loading…
Cancel
Save