Hacker News new | ask | show | jobs
by Const-me 1223 days ago
PSM includes the dependencies, instead of getting rid of them. Not flexible enough.

An example is logging. Geogram includes a logger implementation which uses console streams. GUI apps don't have these streams, they sometimes even deadlock, when an app prints too many characters no one is reading on the other end of the pipe. Geogram includes another file logging implementation in FileLogger class. It uses std::string for path, which doesn’t work on Windows because Windows paths are using UTF-16 encoding.

Also, many parts of Geogram are bypassing the logger API, they directly printing text into std::cerr.

Here’s a possible example of an API which allows to inject custom loggers into DLL libraries:

    // Log level for messages
    enum struct eLogLevel : uint8_t
    {
        Error = 0, Warning = 1, Info = 2, Debug = 3
    };
    // C function pointer to receive log messages from the library. The messages are encoded in UTF-8.
    using pfnLoggerSink = void( __cdecl* )( void* context, eLogLevel lvl, const char* message );
1 comments

Thank you very much for this feedback, it is super useful. Do not hesitate to post this type of comment to geogram's github (https://github.com/BrunoLevy/geogram/issues)

Please note that the Logger mechanism can be redirected to a GUI, it is used for instance in the GUI applications made with Geogram (https://github.com/BrunoLevy/geogram/wiki/Applications) and in Graphite (https://github.com/BrunoLevy/GraphiteThree)

About using std::string as path under Windows, I understand that it may cause some problems with users who use general characters in their directories, but it does not prevent the application from running and from loading/writing files. In the future, when std::filesystem is well standardized, I plan to get read of my FileSystem implementation.