Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging framework #12

Closed
Arkrait opened this issue May 15, 2019 · 12 comments · Fixed by #82
Closed

Logging framework #12

Arkrait opened this issue May 15, 2019 · 12 comments · Fixed by #82
Assignees
Labels
dev team approved A proposal that the development team have approved for implementation. feature A feature ticket for the NovelRT. hacktoberfest Tickets up for grabs for hacktoberfest. help wanted Extra attention is needed proposal A proposal up for debate.

Comments

@Arkrait
Copy link
Contributor

Arkrait commented May 15, 2019

We should probably think about proper logging for the runtime, as logging is incredibly important for projects of any size

AB#3

@Arkrait Arkrait added proposal A proposal up for debate. feature A feature ticket for the NovelRT. labels May 15, 2019
@RubyNova
Copy link
Member

Any suggestions?

What would this look like?

@RubyNova RubyNova added this to To do in NovelRT Engine Core Jul 29, 2019
@Arkrait
Copy link
Contributor Author

Arkrait commented Aug 24, 2019

G3log - basic documentation, no dependencies, async (but not atomic ??? weird), linux only crash handling, code only initialization, no log level filtration except if you use a macro which slows down performance quite a bit, no utf-8 support, mediocre performance over all

Spdlog - basic documentation, uses fmt library for message formatting (this is pretty cool feature imo), one of the best performants, but only if you allocate about ~150 megabytes to it (this seems wrong for our purposes, giving engine 150 more megabytes just for logging), header-only library (few of them), async not atomic

Easylogging - single header lib (~6700 lines), better than basic documentation, not picky of cpu, juicy bundle of util macro, cli flags and file configs support, sync - sinks like file can be painful in bad circumstances, no level filtration looks like
Examples

g3log -

int main() {
    int less = 1; int more = 2
    LOG_IF(INFO, (less<more)) <<"If [true], then this text will be logged";

    // or with printf-like syntax
    LOGF_IF(INFO, (less<more), "if %d<%d then this text will be logged", less,more);
}

Spdlog -

#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"

int main() 
{
    spdlog::info("Welcome to spdlog!");
    spdlog::error("Some error message with arg: {}", 1);
    
    spdlog::warn("Easy padding in numbers like {:08d}", 12);
    spdlog::critical("Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}", 42);
    spdlog::info("Positional args are {1} {0}..", "too", "supported");
    
    spdlog::set_level(spdlog::level::debug); // Set global log level to debug
}

Easylogging -

#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP //thread-safe macro

int main(int argc, const char** argv) {
   el::Configurations defaultConf;
   defaultConf.setToDefault();
    // Values are always std::string
   defaultConf.set(el::Level::Info,
            el::ConfigurationType::Format, "%datetime %level %msg");
    // default logger uses default configurations
    el::Loggers::reconfigureLogger("default", defaultConf);
    LOG(INFO) << "Log using default file";
    // To set GLOBAL configurations you may use
   defaultConf.setGlobally(
            el::ConfigurationType::Format, "%date %msg");
   el::Loggers::reconfigureLogger("default", defaultConf);
    return 0;
}

I suggest using spdlog, it's pretty fast, easy to read and overall a good choice. If everyone agrees on it then I'm going to add logging to novelrt.

@RubyNova RubyNova added the dev team approved A proposal that the development team have approved for implementation. label Aug 29, 2019
@RubyNova RubyNova removed their assignment Oct 3, 2019
@RubyNova RubyNova added hacktoberfest Tickets up for grabs for hacktoberfest. help wanted Extra attention is needed labels Oct 3, 2019
@RubyNova
Copy link
Member

RubyNova commented Oct 3, 2019

Please note whatever logging framework we use MUST be available via vcpkg.

@capnkenny
Copy link
Member

For reference: available logging platforms via vcpkg
image

@RubyNova
Copy link
Member

What would you prefer?

@capnkenny
Copy link
Member

capnkenny commented Oct 10, 2019

Well, from searches for benchmarks I've done, it appears that top 3 are glog, g3log, and spdlog.

Arkrait pretty much hit the nail on the head with the latter two, with glog being the predecessor to g3log - APIs are very similar, but glog is synchronous. Also, since it uses macros, there may be a slight issue if we ever need to pull in a Windows dependency (it defines ERROR, which <windows.h> does as well).

Overall, I think spdlog is the best choice. I'm not quite sure about the allocation issue as mentioned before, but I feel it would be best for our needs. Sounds good?

@RubyNova
Copy link
Member

LGTM, let's do it.

@capnkenny
Copy link
Member

So, to recap:

-Spdlog will be logging framework of choice.
-In this there will be a DEBUG flag established
-All cout and cerr calls will be replaced

@RubyNova
Copy link
Member

Yep that sounds right.

@capnkenny
Copy link
Member

Sounds silly, but last question - would we want to create a service for this? Or just effectively replace the standard calls for now?

@tannergooding
Copy link
Member

Definitely a "service". Anyone, including people using NovelRT will likely want to add minimal logging support and integrating to the built in stuff is likely ideal.

@capnkenny
Copy link
Member

Thanks for the clarification! That's the route I wanted to head, but I just wanted to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev team approved A proposal that the development team have approved for implementation. feature A feature ticket for the NovelRT. hacktoberfest Tickets up for grabs for hacktoberfest. help wanted Extra attention is needed proposal A proposal up for debate.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants