Giter Club home page Giter Club logo

Comments (12)

tannergooding avatar tannergooding commented on June 4, 2024 1

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.

from novelrt.

RubyNova avatar RubyNova commented on June 4, 2024

Any suggestions?

What would this look like?

from novelrt.

Arkrait avatar Arkrait commented on June 4, 2024

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.

from novelrt.

RubyNova avatar RubyNova commented on June 4, 2024

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

from novelrt.

capnkenny avatar capnkenny commented on June 4, 2024

For reference: available logging platforms via vcpkg
image

from novelrt.

RubyNova avatar RubyNova commented on June 4, 2024

What would you prefer?

from novelrt.

capnkenny avatar capnkenny commented on June 4, 2024

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?

from novelrt.

RubyNova avatar RubyNova commented on June 4, 2024

LGTM, let's do it.

from novelrt.

capnkenny avatar capnkenny commented on June 4, 2024

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

from novelrt.

RubyNova avatar RubyNova commented on June 4, 2024

Yep that sounds right.

from novelrt.

capnkenny avatar capnkenny commented on June 4, 2024

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

from novelrt.

capnkenny avatar capnkenny commented on June 4, 2024

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

from novelrt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.