diff --git a/example/example.cpp b/example/example.cpp index 5d588e1b..7fc44850 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -214,13 +214,7 @@ void udp_example() spdlog::sinks::udp_sink_config cfg("127.0.0.1", 11091); auto my_logger = spdlog::udp_logger_mt("udplog", cfg); my_logger->set_level(spdlog::level::debug); - for (int i = 0; i < 10; i++) { - my_logger->info("hello world {}", i); -#ifdef _WIN32 - // sendto() on winsock will drop packets if sent too quickly - std::this_thread::sleep_for(std::chrono::milliseconds(40)); -#endif - } + my_logger->info("hello world"); } // A logger with multiple sinks (stdout and file) - each with a different format and log level. diff --git a/include/spdlog/details/udp_client-windows.h b/include/spdlog/details/udp_client-windows.h index 0eb8cb40..b370b127 100644 --- a/include/spdlog/details/udp_client-windows.h +++ b/include/spdlog/details/udp_client-windows.h @@ -3,6 +3,7 @@ #pragma once +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN // tcp client helper #include @@ -125,4 +126,5 @@ public: } // namespace details } // namespace spdlog -#endif \ No newline at end of file +#endif // _WIN32 +#endif // WIN32_LEAN_AND_MEAN \ No newline at end of file diff --git a/include/spdlog/sinks/udp_sink.h b/include/spdlog/sinks/udp_sink.h index 961d754d..b8706c3d 100644 --- a/include/spdlog/sinks/udp_sink.h +++ b/include/spdlog/sinks/udp_sink.h @@ -17,12 +17,8 @@ #include #include -#pragma once - // Simple udp client sink -// Connects to remote address and send the formatted log. -// Will attempt to reconnect if connection drops. -// If more complicated behaviour is needed (i.e get responses), you can inherit it and override the sink_it_ method. +// Sends formatted log via udp namespace spdlog { namespace sinks { @@ -42,7 +38,6 @@ template class udp_sink : public spdlog::sinks::base_sink { public: - // connect to tcp host/port or throw if failed // host can be hostname or ip address explicit udp_sink(udp_sink_config sink_config)