diff --git a/src/appender.cxx b/src/appender.cxx index efd3702c3..ec967ff22 100644 --- a/src/appender.cxx +++ b/src/appender.cxx @@ -30,6 +30,7 @@ #include #include #include +#include namespace log4cplus @@ -120,6 +121,7 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) LOG4CPLUS_TEXT("Cannot find LayoutFactory: \"") + factoryName + LOG4CPLUS_TEXT("\""), true); + std::unreachable(); } helpers::Properties layoutProperties = @@ -130,6 +132,7 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) helpers::getLogLog().error( LOG4CPLUS_TEXT("Failed to create Layout: ") + factoryName, true); + std::unreachable(); } else { layout = std::move(newLayout); @@ -139,6 +142,7 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) helpers::getLogLog().error( LOG4CPLUS_TEXT("Error while creating Layout: ") + LOG4CPLUS_C_STR_TO_TSTRING(e.what()), true); + std::unreachable(); } } @@ -167,6 +171,7 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) helpers::getLogLog().error( LOG4CPLUS_TEXT("Appender::ctor()- Cannot find FilterFactory: ") + factoryName, true); + std::unreachable(); } spi::FilterPtr tmpFilter = factory->createObject ( filterProps.getPropertySubset(filterName + LOG4CPLUS_TEXT("."))); @@ -175,6 +180,7 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) helpers::getLogLog().error( LOG4CPLUS_TEXT("Appender::ctor()- Failed to create filter: ") + filterName, true); + std::unreachable(); } addFilter (std::move (tmpFilter)); } diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index 5de605871..ddb3da25c 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -24,6 +24,8 @@ #include #ifndef LOG4CPLUS_SINGLE_THREADED +#include + #include #include #include @@ -119,6 +121,7 @@ AsyncAppender::AsyncAppender (helpers::Properties const & props) LOG4CPLUS_TEXT ("AsyncAppender::AsyncAppender()") LOG4CPLUS_TEXT (" - Cannot find AppenderFactory: ") + appender_name, true); + std::unreachable (); } helpers::Properties appender_props = props.getPropertySubset ( diff --git a/src/env.cxx b/src/env.cxx index a9d33c69e..8c1cf5ff6 100644 --- a/src/env.cxx +++ b/src/env.cxx @@ -58,7 +58,7 @@ #include #include #include - +#include namespace log4cplus::internal { @@ -340,10 +340,13 @@ get_current_dir () if (eno == ERANGE) buf_size *= 2; else + { helpers::getLogLog ().error ( LOG4CPLUS_TEXT ("getcwd: ") + helpers::convertIntegerToString (eno), true); + std::unreachable(); + } } } while (! ret); diff --git a/src/lockfile.cxx b/src/lockfile.cxx index b5bd418aa..7899f95e4 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -225,16 +226,22 @@ LockFile::open (int open_flags) const # else # error "Neither _tsopen_s() nor _tsopen() is available." # endif + { getLogLog ().error (tstring (LOG4CPLUS_TEXT("could not open or create file ")) + lock_file_name, true); + std::unreachable (); + } #elif defined (LOG4CPLUS_USE_POSIX_LOCKING) data->fd = ::open (LOG4CPLUS_TSTRING_TO_STRING (lock_file_name).c_str (), open_flags, OPEN_MODE); if (data->fd == -1) + { getLogLog ().error ( tstring (LOG4CPLUS_TEXT ("could not open or create file ")) + lock_file_name, true); + std::unreachable (); + } #if ! defined (O_CLOEXEC) if (! trySetCloseOnExec (data->fd)) @@ -301,8 +308,11 @@ LockFile::lock () const fl.l_len = 0; ret = fcntl (data->fd, F_SETLKW, &fl); if (ret == -1 && errno != EINTR) + { getLogLog ().error (tstring (LOG4CPLUS_TEXT("fcntl(F_SETLKW) failed: ")) + convertIntegerToString (errno), true); + std::unreachable (); + } } while (ret == -1); @@ -354,8 +364,11 @@ void LockFile::unlock () const fl.l_len = 0; ret = fcntl (data->fd, F_SETLKW, &fl); if (ret != 0) + { getLogLog ().error (tstring (LOG4CPLUS_TEXT("fcntl(F_SETLKW) failed: ")) + convertIntegerToString (errno), true); + std::unreachable (); + } #elif defined (LOG4CPLUS_USE_LOCKF) ret = lockf (data->fd, F_ULOCK, 0); diff --git a/src/timehelper.cxx b/src/timehelper.cxx index 663f1d71f..b16a6a756 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #if defined (UNICODE) @@ -304,6 +305,7 @@ getFormattedTime(const log4cplus::tstring& fmt_orig, LogLog::getLogLog ()->error ( LOG4CPLUS_TEXT("Error in strftime(): ") + convertIntegerToString (eno), true); + std::unreachable(); } } }