gabime / spdlog

Fast C++ logging library.
Other
24.39k stars 4.55k forks source link

Add syslog_formatter #3154

Closed sivachandran closed 2 months ago

sivachandran commented 3 months ago

The formatter enables remote(udp/tcp) syslog sink

Example:

    // run "nc -klu 514" to receive the syslog message
    spdlog::sinks::udp_sink_config udp_sink_config("127.0.0.1", 514);
    auto udp_logger = spdlog::udp_logger_mt("udp_logger", udp_sink_config);
    spdlog::syslog_formatter syslog_formatter(spdlog::facility::user, "localhost", "example");
    udp_logger->set_formatter(syslog_formatter.clone());
    udp_logger->info("this message will be logged in local syslog receiver");
gabime commented 2 months ago

Thanks. Since this formatter’s sole purpose is for remote syslog, i suggest having a “remote_syslog” sink instead which would use udp/tcp sink under the hood with the right formatting. This also would make usage much easier without having to use a custom formatter. Also note that some of the ci tests fail. I will close this for now (PR with a new sink is welcome).