twogood / unshield

Tool and library to extract CAB files from InstallShield installers
MIT License
350 stars 75 forks source link

Custom logger function #179

Open bwrsandman opened 11 months ago

bwrsandman commented 11 months ago

When using libunshield, it would be nice to customize where logs get printed to eg. file, logger. This would allow better control of logging and less clutter in stderr when running unshield as a library inside of an application.

I'm thinking something like

libunshield.h

+typedef void (*UnshieldLogCallback)(void* userdata, int level, const char* file, int line, const char* format, ...);
 void unshield_set_log_level(int level);
+void unshield_set_log_handler(UnshieldLogCallback* handler);
+// The contents of current log.h

The current _unshield_log function would become the default handler and unshield_log would be made to forward calls to the current handler.

twogood commented 11 months ago

Good idea! I think that I originally only had logging in the application, not the library.