123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- #ifndef BOOST_LOG_SINKS_SYSLOG_BACKEND_HPP_INCLUDED_
- #define BOOST_LOG_SINKS_SYSLOG_BACKEND_HPP_INCLUDED_
- #include <boost/log/detail/config.hpp>
- #ifdef BOOST_HAS_PRAGMA_ONCE
- #pragma once
- #endif
- #ifndef BOOST_LOG_WITHOUT_SYSLOG
- #include <string>
- #include <boost/log/detail/asio_fwd.hpp>
- #include <boost/log/detail/light_function.hpp>
- #include <boost/log/detail/parameter_tools.hpp>
- #include <boost/log/sinks/basic_sink_backend.hpp>
- #include <boost/log/sinks/syslog_constants.hpp>
- #include <boost/log/sinks/attribute_mapping.hpp>
- #include <boost/log/attributes/attribute_value_set.hpp>
- #include <boost/log/keywords/facility.hpp>
- #include <boost/log/keywords/use_impl.hpp>
- #include <boost/log/keywords/ident.hpp>
- #include <boost/log/keywords/ip_version.hpp>
- #include <boost/log/detail/header.hpp>
- namespace boost {
- BOOST_LOG_OPEN_NAMESPACE
- namespace sinks {
- enum ip_versions
- {
- v4,
- v6
- };
- namespace syslog {
-
- enum impl_types
- {
- #ifdef BOOST_LOG_USE_NATIVE_SYSLOG
- native = 0
- #ifndef BOOST_LOG_NO_ASIO
- ,
- #endif
- #endif
- #ifndef BOOST_LOG_NO_ASIO
- udp_socket_based = 1
- #endif
- };
-
- template< typename AttributeValueT = int >
- class direct_severity_mapping :
- public basic_direct_mapping< level, AttributeValueT >
- {
-
- typedef basic_direct_mapping< level, AttributeValueT > base_type;
- public:
-
- explicit direct_severity_mapping(attribute_name const& name) :
- base_type(name, info)
- {
- }
- };
-
- template< typename AttributeValueT = int >
- class custom_severity_mapping :
- public basic_custom_mapping< level, AttributeValueT >
- {
-
- typedef basic_custom_mapping< level, AttributeValueT > base_type;
- public:
-
- explicit custom_severity_mapping(attribute_name const& name) :
- base_type(name, info)
- {
- }
- };
- }
- class syslog_backend :
- public basic_formatted_sink_backend< char >
- {
-
- typedef basic_formatted_sink_backend< char > base_type;
-
- struct implementation;
- public:
-
- typedef base_type::char_type char_type;
-
- typedef base_type::string_type string_type;
-
- typedef boost::log::aux::light_function< syslog::level (record_view const&) > severity_mapper_type;
- private:
-
- implementation* m_pImpl;
- public:
-
- BOOST_LOG_API syslog_backend();
-
- #ifndef BOOST_LOG_DOXYGEN_PASS
- BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(syslog_backend, construct)
- #else
- template< typename... ArgsT >
- explicit syslog_backend(ArgsT... const& args);
- #endif
-
- BOOST_LOG_API ~syslog_backend();
-
- BOOST_LOG_API void set_severity_mapper(severity_mapper_type const& mapper);
- #if !defined(BOOST_LOG_NO_ASIO)
-
- BOOST_LOG_API void set_local_address(std::string const& addr, unsigned short port = 514);
-
- BOOST_LOG_API void set_local_address(boost::asio::ip::address const& addr, unsigned short port = 514);
-
- BOOST_LOG_API void set_target_address(std::string const& addr, unsigned short port = 514);
-
- BOOST_LOG_API void set_target_address(boost::asio::ip::address const& addr, unsigned short port = 514);
- #endif
-
- BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
- private:
- #ifndef BOOST_LOG_DOXYGEN_PASS
-
- template< typename ArgsT >
- void construct(ArgsT const& args)
- {
- construct(
- args[keywords::facility | syslog::user],
- #if !defined(BOOST_LOG_NO_ASIO)
- args[keywords::use_impl | syslog::udp_socket_based],
- #else
- args[keywords::use_impl | syslog::native],
- #endif
- args[keywords::ip_version | v4],
- args[keywords::ident | std::string()]);
- }
- BOOST_LOG_API void construct(
- syslog::facility facility, syslog::impl_types use_impl, ip_versions ip_version, std::string const& ident);
- #endif
- };
- }
- BOOST_LOG_CLOSE_NAMESPACE
- }
- #include <boost/log/detail/footer.hpp>
- #endif
- #endif
|