1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_COMMON_JOURNALD_H
5 #define CEPH_COMMON_JOURNALD_H
10 #include <sys/socket.h>
14 namespace ceph::logging
{
21 class LogEntryEncoder
;
23 class JournaldClient
{
28 struct msghdr m_msghdr
;
32 enum class MemFileMode
;
33 MemFileMode mem_file_mode
;
35 void detect_mem_file_mode();
44 * Logger to send local logs to journald
46 * local logs means @code dout(0) << ... @endcode and similars
48 * @see JournaldClusterLogger
50 class JournaldLogger
{
52 JournaldLogger(const SubsystemMap
*s
);
56 * @returns 0 if log entry is successfully sent, -1 otherwise.
58 int log_entry(const Entry
&e
);
61 detail::JournaldClient client
;
63 std::unique_ptr
<detail::EntryEncoder
> m_entry_encoder
;
65 const SubsystemMap
* m_subs
;
69 * Logger to send cluster log recieved by MON to journald
73 class JournaldClusterLogger
{
75 JournaldClusterLogger();
76 ~JournaldClusterLogger();
79 * @returns 0 if log entry is successfully sent, -1 otherwise.
81 int log_log_entry(const LogEntry
&le
);
84 detail::JournaldClient client
;
86 std::unique_ptr
<detail::LogEntryEncoder
> m_log_entry_encoder
;
91 class JournaldLogger
{
93 JournaldLogger(const SubsystemMap
*) {}
94 int log_entry(const Entry
&) {
99 class JournaldClusterLogger
{
101 int log_log_entry(const LogEntry
&le
) {
106 #endif // WITH_SYSTEMD