Display error if broker unable to open the log file.

Thanks to Matthew Treinish.

Bug: https://github.com/eclipse/mosquitto/issues/234
pull/260/head
Roger A. Light 9 years ago
parent 477cd3e399
commit ba2de88790

@ -11,6 +11,8 @@ Broker:
#189.
- Fix persistence saving of subscription QoS on big-endian machines.
- Fix will retained flag handling on Windows. Closes #222.
- Broker now displays an error if it is unable to open the log file. Closes
#234.
Client library:
- Support OpenSSL 1.1.0.

@ -71,6 +71,8 @@ int mqtt3_log_init(struct mqtt3_config *config)
}
config->log_fptr = _mosquitto_fopen(config->log_file, "at");
if(!config->log_fptr){
log_destinations = MQTT3_LOG_STDERR;
log_priorities = MOSQ_LOG_ERR;
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open log file %s for writing.", config->log_file);
return MOSQ_ERR_INVAL;
}

@ -287,7 +287,10 @@ int main(int argc, char *argv[])
/* Initialise logging only after initialising the database in case we're
* logging to topics */
mqtt3_log_init(&config);
if(mqtt3_log_init(&config)){
rc = 1;
return rc;
}
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "mosquitto version %s (build date %s) starting", VERSION, TIMESTAMP);
if(config.config_file){
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "Config loaded from %s.", config.config_file);

Loading…
Cancel
Save