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

Add a proper logging system #12

Open
nasso opened this issue May 22, 2021 · 4 comments
Open

Add a proper logging system #12

nasso opened this issue May 22, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nasso
Copy link
Owner

nasso commented May 22, 2021

Due to the complexity of a game engine, logging is pretty much required to keep track of what's going on. Currently, everything is written directly to the standard outputs using std::cout and std::cerr. A proper logging system would instead allow us to write log messages anywhere (e.g. to a file on disk, send them over the network, or display them in an in-game console).

Most game engines have some way handling logging with various levels of verbosity. The most common levels available are:

  1. Critical error messages
  2. Warning messages
  3. General purpose information
  4. Debugging messages
  5. Trace (very verbose)

These levels are commonly identified by an integer like in the ordered list above. The logger then has routines to filter messages to the ones we are interested in only.

Proposed interface

Setting the current log level should probably be just a function call with an enum value:

using ige::log::LogLevel;

ige::log::set_log_level(LogLevel::DEBUG);

An idiomatic C++ interface for logging messages could look like the following:

ige::log::error << "Error";
ige::log::warn << "Warning" ;
ige::log::info << "Information";
ige::log::debug << "Debug message";
ige::log::trace << "Low level trace that won't be shown";

However, some logging libraries prefer C-style IO for performance reasons.

Either way, effort should be made to be as lazy as possible for disabled log levels. Writing to ige::log::trace should be as light as possible when the current logging level is lower than TRACE.

Some popular logging libraries in the C++ world:

@nasso nasso added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels May 22, 2021
@yasster
Copy link

yasster commented Jun 1, 2021

Hey! I can take on the issue. Would you want a new implementation or a wrapper to one of the libraries you mentioned? I've used spdlog before

@nasso
Copy link
Owner Author

nasso commented Jun 1, 2021

Hey! I'm happy you're interested in contributing to my project! For my needs, I think it's better if it's a new (simplistic) implementation. The reason for this is that I'm developing this engine for use in a school project, which also means I might not be able to merge your pull request right away. Feel free to open one though, I will merge it once I'm allowed to :)

@nasso
Copy link
Owner Author

nasso commented Jun 1, 2021

Just got confirmation, I am in fact allowed to accept contributions, should I assign you to this issue?

@yasster
Copy link

yasster commented Jun 1, 2021

Yeah! I'll get started on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants