![Cristian Morales Vega](/assets/img/avatar_default.png)
The meaning of using quotes to #include is implementation defined, so it may or not may be what we want. At least POSIX (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html) says: "headers whose names are enclosed in double-quotes ( "" ) shall be searched for first in the directory of the file with the #include line", so not what we want since "spdlog" ends up twice in the path.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
#pragma once
|
|
|
|
#ifndef SPDLOG_HEADER_ONLY
|
|
#include <spdlog/common.h>
|
|
#endif
|
|
|
|
namespace spdlog {
|
|
namespace level {
|
|
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
|
|
|
|
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
|
|
|
|
SPDLOG_INLINE string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
|
|
{
|
|
return level_string_views[l];
|
|
}
|
|
|
|
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
|
|
{
|
|
return short_level_names[l];
|
|
}
|
|
|
|
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
|
|
{
|
|
int level = 0;
|
|
for (const auto &level_str : level_string_views)
|
|
{
|
|
if (level_str == name)
|
|
{
|
|
return static_cast<level::level_enum>(level);
|
|
}
|
|
level++;
|
|
}
|
|
return level::off;
|
|
}
|
|
} // namespace level
|
|
|
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
|
|
: msg_(std::move(msg))
|
|
{}
|
|
|
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
|
|
{
|
|
memory_buf_t outbuf;
|
|
fmt::format_system_error(outbuf, last_errno, msg);
|
|
msg_ = fmt::to_string(outbuf);
|
|
}
|
|
|
|
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT
|
|
{
|
|
return msg_.c_str();
|
|
}
|
|
|
|
} // namespace spdlog
|