1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef __CEPH_LOG_GRAYLOG_H
5 #define __CEPH_LOG_GRAYLOG_H
7 #include <boost/asio.hpp>
8 #include <boost/iostreams/filtering_stream.hpp>
9 #include <boost/iostreams/filter/zlib.hpp>
11 #include "include/memory.h"
12 #include "include/assert.h" // boost clobbers this
26 // Graylog logging backend: Convert log datastructures (LogEntry, Entry) to
27 // GELF (http://www.graylog2.org/resources/gelf/specification) and send it
28 // to a GELF UDP receiver
35 * Create Graylog with SubsystemMap. log_entry will resolve the subsystem
36 * id to string. Logging will not be ready until set_destination is called
37 * @param s SubsystemMap
38 * @param logger Value for key "_logger" in GELF
40 Graylog(const SubsystemMap * const s, std::string logger);
43 * Create Graylog without SubsystemMap. Logging will not be ready
44 * until set_destination is called
45 * @param logger Value for key "_logger" in GELF
47 explicit Graylog(std::string logger);
50 void set_hostname(const std::string& host);
51 void set_fsid(const uuid_d& fsid);
53 void set_destination(const std::string& host, int port);
55 void log_entry(Entry const * const e);
56 void log_log_entry(LogEntry const * const e);
58 typedef ceph::shared_ptr<Graylog> Ref;
61 SubsystemMap const * const m_subs;
65 std::string m_hostname;
69 boost::asio::ip::udp::endpoint m_endpoint;
70 boost::asio::io_service m_io_service;
72 std::unique_ptr<Formatter> m_formatter;
73 std::unique_ptr<Formatter> m_formatter_section;
74 std::stringstream m_ostream_section;
75 std::stringstream m_ostream_compressed;
76 boost::iostreams::filtering_ostream m_ostream;
77 boost::iostreams::zlib_compressor m_compressor;