问题标签 [easylogging++]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
958 浏览

opengl - GLSDK 打破了easylogging++

我正在启动一个 OpenGL 引擎,使用 SFML 作为上下文和输入管理器,使用 GLSDK 来加载 OpenGL(以及现在不重要的图像和东西),并使用 Boost 来处理其他一些事情。

我一直在想“记录”的想法,并尝试了 Boost.Log(未能编译一个示例,并且对该问题的唯一引用未解决),Log4CPP(在启动时出现错误),最后一切似乎都是easylogging++ 很好,它是一个只有头文件的库(好样的!),它有一些简洁的语法 IMO。

但它在编译时给出了一堆错误:

  • C2664: 'el::base::utils::DateTime::gettimeofday' : 无法将参数 1 从 'int *' 转换为 'el::base::utils::timeval *'

  • C2228: '.tv_usec' 的左边必须有类/结构/联合

  • C2227:“->tv_usec”左侧必须指向类/结构/联合/通用类型
  • C2079:“currTime”使用未定义的结构“el::base::utils::timeval”
  • C2027:使用未定义类型 'el::base::utils::timeval'
  • 还有一些

我已经以这种方式实现了它:

  • 'helpers.Log.hpp':pragma once,包括 'easylogging++.h' 并定义命名空间助手 > 命名空间日志 > void function init()。
  • 'helpers.Log.cpp': '_INITIALIZE_EASYLOGGINGPP' 并实现 init() 如下:

    /li>

现在,只有这两个文件处理 logging。“engine.Core.hpp”包括“helpers.Log.hpp”、“engine.Boot.hpp”(现在为空白)、“glload/gl_load.hpp”、“glload/gl_3_3.hpp”以及在核心类,在引擎命名空间内,调用了 init() 函数。

在整个应用程序中没有做任何其他事情。就是这样,日志系统的初始化,但它完全失败了。

系统信息

操作系统:Windows 7 x64

IDE:Visual Studio 2012

编译器: VS2012 (v110)

编译命令:cl /c /IF:/BTSync/prog_projs/KINGDOMS/trunk/inc /IF:/dev/SFML/21/include /IF:/dev/GLSDK/052/glload/include /IF:/dev/GLSDK /052/glutil/include /IF:/dev/GLSDK/052/glm /IF:/dev/GLSDK/052/glmesh/include /IF:/dev/GLSDK/052/glimage/include /IF:/dev/BOOST /154 /IF:/DEV/LIBROCKET/121_3/include /Zi /nologo- /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"KINGDOMS_0_1.dir\Debug\" /Fd"F:/BTSync/prog_projs/KINGDOMS/ trunk/pro/Debug/KINGDOMS_0_1_d.pdb" /Gd /TP /analyze- /errorReport:prompt ..\src\engine.Boot.cpp ..\src\engine.Core.cpp ..\src\engine.Interfaces。 cpp ..\src\helpers.Log.cpp ..\src\main.cpp

出版前编辑:好的,所以看起来“glload/gl_3_3.hpp”是这里的问题。它设法打破了easylogging++。那是我的事。这怎么可能呢?我能做些什么?

编辑以添加真实代码

引擎.Core.hpp

引擎.Core.cpp

助手.Log.hpp

助手.Log.cpp

0 投票
1 回答
2389 浏览

c++ - Easylogging++如何配置单个宏?

我想创建一个简单的宏,它可以做什么_INITIALIZE_EASYLOGGINGPP,但它接受一个像这样的配置字符串:

然后宏将替换:

经过

任何人都知道如何做到这一点?

0 投票
2 回答
1473 浏览

logging - easylogging++:在应用程序启动时清除日志文件

我最近在我的 C++ 应用程序中采用了Easylogging++,并且遇到了我希望他们的文档中遗漏的内容。

我希望每次启动我的应用程序时都清除我的日志文件,而不是从以前的应用程序实例中附加日志事件。我意识到我可以在任何日志记录事件之前在启动时删除日志文件,但这似乎是一个 hack。

任何帮助,将不胜感激。谢谢。

0 投票
1 回答
950 浏览

c++ - 没有 c++11,Easylogging 8.91 无法编译

我想在没有 C++11 的情况下使用该库,但它不会为我编译:(理论上它应该按照文档 @ http://easylogging.muflihun.com:“对于较低版本的 C++(非 C++ 11)、请考虑使用Easylogging++ v8.91。")

错误:#error 此文件需要对 ISO C++ 2011 标准的编译器和库支持。此支持目前是实验性的,必须使用 -std=c++11 或 -std=gnu++11 编译器选项启用。

文件结构:

./Main.cpp ./logger/easylogging++.h

Main.cpp 的内容:

../src/logger/easylogging++.h:在函数'std::string easyloggingpp::internal::threading::getCurrentThreadId()'中:../src/logger/easylogging++.h:691:16:错误:' std::this_thread' 尚未声明 ss << std::this_thread::get_id();

编译器:gcc 版本 4.8.2(Ubuntu 4.8.2-19ubuntu1),操作系统:Ubuntu 14.04 LTS

0 投票
1 回答
537 浏览

logging - 任何使用easylogging++的经验

我一直在寻找一个相对简单的没有依赖关系的日志记录选项,并注意到 easylogging++。它看起来很成熟,有据可查,usint 测试。

开始使用它,但遇到了一些难以发现且难以调试的问题。

我想知道是否有人使用过easylogging++,它是否可靠。?

0 投票
0 回答
18 浏览

c++ - 如何让easyloggingpp在macosx上工作?

我正在尝试在 MacOSx 上使用 easyloggingpp ( https://github.com/easylogging/easyloggingpp ) 和 clion 中的 clang。仅包含 easyloggingc++.h 文件不起作用,我收到以下错误。

似乎缺少一些符号,但实际上,easyloggingpp只有一个头文件,所以我不确定缺少什么。

MWE:

0 投票
1 回答
338 浏览

c++ - Is it possible to create a C++ class that mimics the std::cout syntax by chaining overloaded insertion operators the same way that easylogging++ does?

The easylogging++ code defines a macro that makes it very simple to use:

I want to make a wrapper class for easylogging++. I can easily create a function with two parameters to wrap the above line. However, is it possible to mimic this syntax in a wrapper class? For example:

I know I can easily overload the insertion operator, but that still leaves me with having to write another function to set the log level each time.

UPDATE:

Thanks to Starl1ght's answer I was able to get this working. I figured I would share in case anyone else has a similar need.

I created two overloads. One was for () and the other for <<.

UPDATE 2:

I wanted to update this post again to give my reasoning and show my final solution.

My reasoning is that my project is a demonstration of abstraction. I'm trying to demonstrate that logging libraries (and many other things) can be abstracted away from the core functionality of your software. This also makes the software components modular. This way I can swap out the easylogging++ library without loosing the syntax because it is implemented in the module interface.

My last update didn't mention how I overcame the obstacle of insertion chaining, so I wanted to post an example to show how I did it. The following code is a simplified example of how to achieve std::cout like syntax for a class.

I feel like I could have done a better job with the naming and the comments but I am pressed for time. I'm definitely open to any comments or critiques.

0 投票
3 回答
664 浏览

c++ - 在项目中只调用一次宏

我正在尝试easylogging++在项目中设置,我遇到了以下问题:

INITIALIZE_EASYLOGGINGPP应该在项目中只调用一次。现在,如果我从我的宏中调用这个宏main.cpp并且只包含easylogging++.hmain.cpp- 一切正常。但是,当我尝试包含easylogging++.h在更多.cpp文件中时,我会遇到未定义引用的链接器问题(好像尚未调用宏)。如果我将此宏的调用放在按字母顺序排列在 之前的文件中,则main.cpp链接器会正常解析所有内容。在链接阶段,对象按字母顺序排序。

有没有很好的方法来解决这个问题?或者我是否必须尝试在链接时强制使用不同的文件顺序?

我对这类问题没有太多经验,尝试谷歌搜索,找不到解决方案。如果已经有类似的问题,抱歉,找不到。

谢谢您的帮助!

0 投票
0 回答
50 浏览

c++ - operator<< 仅在 Linux 中调用

我在一个“大”跨平台项目中使用easyloggingpp 。足够大,以至于我无法创建一个简单的运行示例来重现我将要描述的行为。

所以我enum在一些标题中定义了一些类型,比如说:

types.h

枚举是一个C枚举,因为该项目是 ABI 安全的,并且 API 是 C 函数和类型的薄层(我们对沙漏模式的实现)

它还有两个处理打印的函数,假设这些是函数(实际上只有函数的主体不同):

types.cpp中,我有:

如果我在我的代码中调用这样的东西

函数中的assert(0)get_string()将被触发。

但是如果我打电话给记录器:

出于某种原因,在 Visual Studio(2017 如果重要)中,当调用记录器的内部流成员(也是类型std::stringstream)时,x它会调用<ostream>函数:_Myt& __CLR_OR_THIS_CALL operator<<(int _Val),即它将枚举视为整数,并将值打印为一个数字,而不是使用我的运算符重载。

但是,在 Linux 中 - 用 编译的相同代码gcc 5.4.0调用 myoperator<<并触发断言。

我真的不知道从哪里开始才能理解这一点......

所以真正的问题是 - 什么会导致编译器\操作系统之间存在这种差异?我从哪里开始调试它?或者如果有人知道是什么原因造成的,我很想知道。

编辑:

LOG_INFO是最终调用的日志基础设施的宏: m_logger->stream() << msg;wherem_logger->stream()返回std::stringstream&并且msg是模板化的值参数,在我的示例中是x

0 投票
1 回答
138 浏览

c++ - 使用 easylogging++ 记录 QString 时插入的额外空间

我有多行代码触发记录器(信息模式):

输出示例如下所示:

我遇到的问题是似乎附加在各个QString::number()调用前面的额外空间(下面的空格标有 # 以使它们更明显):

我正在寻找以下输出:

我需要为此输出使用 INFO。我习惯于LOG(DEBUG)在整个地方放置额外的空间,但没想到LOG(INFO).