0

我已经从 git repo 手动安装了 spdlog,版本为 version.h 中的 1.3.1。现在我正在尝试执行存储库中给出的基本示例,但它们给出了某些错误。同步记录器示例运行良好。

我尝试了 2 个示例:使用 spdlog 的异步记录器创建和具有多个接收器的异步记录器

myAsyncLogger.cpp

#include "spdlog/async.h" //support for async logging.
#include "spdlog/sinks/basic_file_sink.h"
#include <iostream>


int main(int, char* [])
{
    try
    {        
        auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
       for (int i = 1; i < 101; ++i)
      {
         async_file->info("Async message #{}", i);
      }
       // Under VisualStudio, this must be called before main finishes to workaround a known VS issue
        spdlog::drop_all(); 
    }
    catch (const spdlog::spdlog_ex& ex)
    {
        std::cout << "Log initialization failed: " << ex.what() << std::endl;
    }
}

编译为 :clang++ -o logAsync logAsync.cpp

给出以下错误:

In file included from ./spdlog/async.h:21:
In file included from /usr/local/include/spdlog/details/registry.h:22:
In file included from /usr/local/include/spdlog/sinks/ansicolor_sink.h:9:
/usr/local/include/spdlog/spdlog.h:32:18: error: no member named 'registry' in namespace 'spdlog::details'
        details::registry::instance().initialize_logger(new_logger);
        ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:55:21: error: no member named 'registry' in namespace 'spdlog::details'
    return details::registry::instance().get(name);
           ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:61:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().set_formatter(std::move(formatter));
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:74:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().set_level(log_level);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:80:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().flush_on(log_level);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:87:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().flush_every(interval);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:93:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().set_error_handler(std::move(handler));
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:99:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().register_logger(std::move(logger));
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:107:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().apply_all(fun);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:113:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().drop(name);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:119:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().drop_all();
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:125:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().shutdown();
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:131:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().set_automatic_registration(automatic_registation);
    ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:151:21: error: no member named 'registry' in namespace 'spdlog::details'
    return details::registry::instance().default_logger();
           ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:156:21: error: no member named 'registry' in namespace 'spdlog::details'
    return details::registry::instance().get_default_raw();
           ~~~~~~~~~^
/usr/local/include/spdlog/spdlog.h:161:14: error: no member named 'registry' in namespace 'spdlog::details'
    details::registry::instance().set_default_logger(std::move(default_logger));
    ~~~~~~~~~^
16 errors generated.

我期待它应该可以正常工作,因为我正在使用 clang++ , c++11

4

1 回答 1

0

是的,实际上我已经解决了。对于寻找其解决方案的人,请参阅 [Link] https://github.com/gabime/spdlog/issues/1014

于 2019-04-09T11:25:28.090 回答