使用syslog后端进行Boost.Log异步日志记录

时间:2020-03-25 16:36:25

标签: c++ asynchronous logging boost syslog

我在Boost.log上实现了一个包装器,用于记录同步和异步方式。在下面,我用syslog_backend定义了异步接收器前端。

typedef sinks::asynchronous_sink<
    sinks::syslog_backend,
    sinks::unbounded_ordering_queue<
    logging::attribute_value_ordering< unsigned int, std::less< unsigned int > >
>
> Async_syslog_sink;

但是在init()内部,当我使用此定义创建后端并添加到logging :: core时,发生了错误。

// Create a backend
boost::shared_ptr< Async_syslog_sink > sink(new Async_syslog_sink(
    keywords::facility = sinks::syslog::user,
    keywords::use_impl = sinks::syslog::native
));
sink->set_formatter(&my_formatter);
logging::core::get()->add_sink(sink);

错误是:

/usr/include/boost/log/sinks/async_frontend.hpp:在实例化 ‘boost :: log :: v2_mt_posix :: sinks :: asynchronous_sink :: asynchronous_sink(bool)[with SinkBackendT = boost :: log :: v2_mt_posix :: sinks :: syslog_backend; QueueingStrategyT = boost :: log :: v2_mt_posix :: sinks :: unbounded_ordering_queue>>]’: /root/sample-logger/src/Loggers/Async/AsyncLogger.h:314:9:
从这里需要 /usr/include/boost/log/sinks/async_frontend.hpp:230:31:错误:否 调用的匹配功能 ‘boost :: log :: v2_mt_posix :: sinks :: unbounded_ordering_queue>> :: unbounded_ordering_queue()” m_FlushRequested(false)

我如何拥有一个带有syslog后端的异步记录器?

谢谢。

1 个答案:

答案 0 :(得分:1)

您需要在接收器构造函数的import java.util.Scanner; import APP.*; public class AppointmentTest { public static void main(String[] args) { Appointment app = new Appointment(); String m, y; double st, et; //char c; String c; Scanner input = new Scanner (System.in); do { System.out.print("Enter name for the appointment :"); m = input.nextLine(); app.setName(m); System.out.print("Enter day appointment :"); y = input.nextLine(); app.setDay(y); System.out.print("Enter start time :"); st = input.nextDouble(); app.setStartTime(st); System.out.print("Enter end time :"); et = input.nextDouble(); app.setEndTime(et); System.out.println("Duration of appointment :"); System.out.print("Do you have any other appointment? (Y/N) :"); //c = input.next().charAt(0); c = input.next(); }while (c != "N" && c != "n"); } 命名参数中提供一个排序谓词。假设您使用keywords::order,则在构造谓词时应指定要基于其排序日志记录的属性名称。例如:

logging::attribute_value_ordering