26 #include <boost/regex.hpp> 27 #include <sys/types.h> 28 #include <sys/socket.h> 52 if (!icl_core::config::get<icl_core::String>(config_prefix +
"/Host", server_host))
54 std::cerr <<
"No Host specified for UDP log output stream " << config_prefix <<
std::endl;
58 icl_core::config::getDefault<icl_core::String>(config_prefix +
"/Port",
"60000");
60 if (!icl_core::config::get<icl_core::String>(config_prefix +
"/SystemName",
m_system_name))
62 std::cerr <<
"No SystemName specified for UDP log output stream " << config_prefix <<
std::endl;
66 struct addrinfo hints;
67 memset (&hints, 0,
sizeof(hints));
68 hints.ai_family = AF_INET;
69 hints.ai_socktype = SOCK_DGRAM;
71 struct addrinfo *res = 0, *res0 = 0;
72 int n = getaddrinfo(server_host.c_str (), server_port.c_str (), &hints, &res0);
75 for (res = res0; res != NULL &&
m_socket < 0; res = res->ai_next)
77 m_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
80 if (connect(m_socket, res->ai_addr, res->ai_addrlen) < 0)
104 std::stringstream ss;
109 <<
"'" << log_message.
filename <<
"'," << log_message.
line <<
"," 114 std::string str = ss.str();
115 int res = write(
m_socket, str.c_str(), str.length());
118 perror(
"UdpLogOutput::pushImpl()");
127 str = boost::regex_replace(str, boost::regex(
"'"),
"\\'");
Contains helper functions for dealing with String.
icl_core::TimeStamp timestamp
char filename[cMAX_DESCRIPTION_LENGTH+1]
UdpLogOutput(const icl_core::String &name, const icl_core::String &config_prefix, icl_core::logging::LogLevel log_level)
Base header file for the configuration framework.
icl_core::logging::LogLevel log_level
#define REGISTER_LOG_OUTPUT_STREAM(name, factory)
static LogOutputStream * create(const icl_core::String &name, const icl_core::String &config_prefix, icl_core::logging::LogLevel log_level=cDEFAULT_LOG_LEVEL)
Contains icl_logging::UdpLogOutput.
ThreadStream & endl(ThreadStream &stream)
char message_text[cDEFAULT_LOG_SIZE+1]
char object_name[cMAX_DESCRIPTION_LENGTH+1]
This is an output stream class for log messages.
virtual void pushImpl(const LogMessage &log_message)
char class_name[cMAX_IDENTIFIER_LENGTH+1]
icl_core::String m_system_name
void * memset(void *dest, int c, size_t count)
char function_name[cMAX_IDENTIFIER_LENGTH+1]
char log_stream[cMAX_IDENTIFIER_LENGTH+1]
const char * logLevelDescription(LogLevel log_level)
Defines an entry for the message queue.
String formatIso8601() const
icl_core::String escape(icl_core::String str) const