Error when log file cannot be opened. (#4460)

This commit is contained in:
Giovanni 2024-04-23 18:44:15 +08:00 committed by GitHub
parent e08ceb9bd7
commit 058a848e43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2880,9 +2880,13 @@ static bool cb_log_config_abortlevel(void *coreptr, void *nodeptr) {
} }
#endif /* RZ_BUILD_DEBUG */ #endif /* RZ_BUILD_DEBUG */
static bool cb_log_config_file(void *coreptr, void *nodeptr) { static bool cb_log_file(void *coreptr, void *nodeptr) {
RzConfigNode *node = (RzConfigNode *)nodeptr; RzConfigNode *node = (RzConfigNode *)nodeptr;
return rz_log_set_file(node->value); if (!rz_log_set_file(node->value)) {
RZ_LOG_ERROR("log.file: cannot open '%s'\n", node->value);
return false;
}
return true;
} }
static bool cb_log_config_show_sources(void *coreptr, void *nodeptr) { static bool cb_log_config_show_sources(void *coreptr, void *nodeptr) {
@ -3349,7 +3353,7 @@ RZ_API int rz_core_config_init(RzCore *core) {
// RZ_LOGFILE / log.file // RZ_LOGFILE / log.file
p = rz_sys_getenv("RZ_LOGFILE"); p = rz_sys_getenv("RZ_LOGFILE");
SETCB("log.file", p ? p : "", cb_log_config_file, "Logging output filename / path"); SETCB("log.file", p ? p : "", cb_log_file, "Logging output filename / path");
free(p); free(p);
// RZ_LOGSHOWSOURCES / log.show.sources // RZ_LOGSHOWSOURCES / log.show.sources