mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-01 02:42:41 +08:00
astyle
This commit is contained in:
parent
a9dbfb8b0e
commit
ece27ac952
@ -64,10 +64,10 @@ int main(int, char* [])
|
|||||||
SPDLOG_TRACE(file_logger, "This is a trace message (only #ifdef _DEBUG)", 123);
|
SPDLOG_TRACE(file_logger, "This is a trace message (only #ifdef _DEBUG)", 123);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
auto syslog_logger = spd::syslog_logger("syslog");
|
auto syslog_logger = spd::syslog_logger("syslog");
|
||||||
syslog_logger->warn("This is warning that will end up in syslog. This is Linux only!");
|
syslog_logger->warn("This is warning that will end up in syslog. This is Linux only!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (const spd::spdlog_ex& ex)
|
catch (const spd::spdlog_ex& ex)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,8 @@ typedef enum
|
|||||||
} level_enum;
|
} level_enum;
|
||||||
|
|
||||||
static const char* level_names[] { "trace", "debug", "info", "notice", "warning", "error", "critical",
|
static const char* level_names[] { "trace", "debug", "info", "notice", "warning", "error", "critical",
|
||||||
"alert", "emerg", "", ""};
|
"alert", "emerg", "", ""
|
||||||
|
};
|
||||||
inline const char* to_str(spdlog::level::level_enum l)
|
inline const char* to_str(spdlog::level::level_enum l)
|
||||||
{
|
{
|
||||||
return level_names[l];
|
return level_names[l];
|
||||||
|
@ -35,16 +35,16 @@
|
|||||||
|
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
namespace sinks
|
namespace sinks
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Sink that write to syslog using the `syscall()` library call.
|
* Sink that write to syslog using the `syscall()` library call.
|
||||||
*
|
*
|
||||||
* Locking is not needed, as `syslog()` itself is thread-safe.
|
* Locking is not needed, as `syslog()` itself is thread-safe.
|
||||||
*/
|
*/
|
||||||
class syslog_sink : public sink
|
class syslog_sink : public sink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
syslog_sink()
|
syslog_sink()
|
||||||
{
|
{
|
||||||
_priorities[static_cast<int>(level::TRACE)] = LOG_DEBUG;
|
_priorities[static_cast<int>(level::TRACE)] = LOG_DEBUG;
|
||||||
@ -70,7 +70,7 @@ namespace spdlog
|
|||||||
syslog(syslog_prio_from_level(msg), "%s", msg.formatted.str().c_str());
|
syslog(syslog_prio_from_level(msg), "%s", msg.formatted.str().c_str());
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Simply maps spdlog's log level to syslog priority level.
|
* Simply maps spdlog's log level to syslog priority level.
|
||||||
*/
|
*/
|
||||||
@ -79,10 +79,10 @@ namespace spdlog
|
|||||||
return _priorities[static_cast<int>(msg.level)];
|
return _priorities[static_cast<int>(msg.level)];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<int, 11> _priorities;
|
std::array<int, 11> _priorities;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,7 +70,7 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name);
|
|||||||
|
|
||||||
// Create a syslog logger
|
// Create a syslog logger
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
std::shared_ptr<logger> syslog_logger(const std::string& logger_name);
|
std::shared_ptr<logger> syslog_logger(const std::string& logger_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user