Handle failure to open log file
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@258 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip-apps/src/pjsua/main.c b/pjsip-apps/src/pjsua/main.c
index d8539a7..7f99954 100644
--- a/pjsip-apps/src/pjsua/main.c
+++ b/pjsip-apps/src/pjsua/main.c
@@ -846,7 +846,7 @@
}
-void app_logging_init(void)
+pj_status_t app_logging_init(void)
{
/* Redirect log function to ours */
@@ -854,8 +854,16 @@
/* If output log file is desired, create the file: */
- if (pjsua.log_filename)
+ if (pjsua.log_filename) {
log_file = fopen(pjsua.log_filename, "wt");
+ if (log_file == NULL) {
+ PJ_LOG(1,(THIS_FILE, "Unable to open log file %s",
+ pjsua.log_filename));
+ return -1;
+ }
+ }
+
+ return PJ_SUCCESS;
}
@@ -911,7 +919,8 @@
/* Init logging: */
- app_logging_init();
+ if (app_logging_init() != PJ_SUCCESS)
+ return 1;
/* Register message logger to print incoming and outgoing