mondradiko / mdo-core

1 stars 1 forks source link

Custom logging #3

Closed marceline-cramer closed 3 years ago

marceline-cramer commented 3 years ago

In almost every source file right now, there are TODOs right at the top that look something like this:

/* TODO(marceline-cramer): custom logging */
#include <stdio.h> /* for fprintf */

Then, those source files use fprintf to do basic error logging. This is suboptimal, because the error messages have to include the full context of the source code that they come from explicitly to be useful as debug messages. They are also uncolored, and have no filterable severity (info, debug, warning, error, message).

I've already written logging functionality to solve these problems in the mdo-utils repository: https://github.com/mondradiko/mdo-utils/blob/main/include/log.h https://github.com/mondradiko/mdo-utils/blob/main/src/log.c

There are four simple steps to improving the logging now:

If you have any questions, such as regarding which severity each debug message should be made as you come across them, ask in this issue and I'll answer them.