mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 11:29:01 +08:00
wip - no-exceptions support
This commit is contained in:
@@ -39,14 +39,14 @@ SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate)
|
||||
details::os::sleep_for_millis(open_interval);
|
||||
}
|
||||
|
||||
throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
|
||||
SPDLOG_THROW spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void file_helper::reopen(bool truncate)
|
||||
{
|
||||
if (_filename.empty())
|
||||
{
|
||||
throw spdlog_ex("Failed re opening file - was not opened before");
|
||||
SPDLOG_THROW spdlog_ex("Failed re opening file - was not opened before");
|
||||
}
|
||||
open(_filename, truncate);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ SPDLOG_INLINE void file_helper::write(const fmt::memory_buffer &buf)
|
||||
auto data = buf.data();
|
||||
if (std::fwrite(data, 1, msg_size, fd_) != msg_size)
|
||||
{
|
||||
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
|
||||
SPDLOG_THROW spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ SPDLOG_INLINE size_t file_helper::size() const
|
||||
{
|
||||
if (fd_ == nullptr)
|
||||
{
|
||||
throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
|
||||
SPDLOG_THROW spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
|
||||
}
|
||||
return os::filesize(fd_);
|
||||
}
|
||||
|
@@ -120,13 +120,13 @@ SPDLOG_INLINE void prevent_child_fd(FILE *f)
|
||||
#if !defined(__cplusplus_winrt)
|
||||
auto file_handle = reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(f)));
|
||||
if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0))
|
||||
throw spdlog_ex("SetHandleInformation failed", errno);
|
||||
SPDLOG_THROW spdlog_ex("SetHandleInformation failed", errno);
|
||||
#endif
|
||||
#else
|
||||
auto fd = fileno(f);
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
{
|
||||
throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno);
|
||||
SPDLOG_THROW spdlog_ex("fcntl with FD_CLOEXEC failed", errno);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -192,7 +192,7 @@ SPDLOG_INLINE size_t filesize(FILE *f)
|
||||
{
|
||||
if (f == nullptr)
|
||||
{
|
||||
throw spdlog_ex("Failed getting file size. fd is null");
|
||||
SPDLOG_THROW spdlog_ex("Failed getting file size. fd is null");
|
||||
}
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
int fd = _fileno(f);
|
||||
@@ -229,7 +229,7 @@ SPDLOG_INLINE size_t filesize(FILE *f)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
throw spdlog_ex("Failed getting file size from fd", errno);
|
||||
SPDLOG_THROW spdlog_ex("Failed getting file size from fd", errno);
|
||||
}
|
||||
|
||||
// Return utc offset in minutes or throw spdlog_ex on failure
|
||||
|
@@ -245,7 +245,7 @@ SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name)
|
||||
{
|
||||
if (loggers_.find(logger_name) != loggers_.end())
|
||||
{
|
||||
throw spdlog_ex("logger with name '" + logger_name + "' already exists");
|
||||
SPDLOG_THROW spdlog_ex("logger with name '" + logger_name + "' already exists");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n, std
|
||||
{
|
||||
if (threads_n == 0 || threads_n > 1000)
|
||||
{
|
||||
throw spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid "
|
||||
SPDLOG_THROW spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid "
|
||||
"range is 1-1000)");
|
||||
}
|
||||
for (size_t i = 0; i < threads_n; i++)
|
||||
|
Reference in New Issue
Block a user