Open gkprow-runsafe opened 3 years ago
This is already how the core API works:
// Callbacks
struct BNLogListener
{
void* context;
void (*log)(void* ctxt, BNLogLevel level, const char* msg);
void (*close)(void* ctxt);
BNLogLevel (*getLogLevel)(void* ctxt);
};
BINARYNINJACOREAPI void BNRegisterLogListener(BNLogListener* listener);
BINARYNINJACOREAPI void BNUnregisterLogListener(BNLogListener* listener);
BINARYNINJACOREAPI void BNUpdateLogListeners(void);
There's just no Python wrapper for that part currently. It'd be easy to wrap that native API as an addition to log.py, if you wanted to submit a PR?
Sure thing. I'll work to create a PR.
Changing title to reflect actual issue.
Current Binja release: Version 2.2.2603-dev (Build ID 8f9fea38)
Current functionality: The logging API allows users to limit which LogLevels should be written to stdout/err, to enable writing logs to a file, etc. But, when a log message is written to stdout/err or a file, only the message itself is written. No metadata is written along with the message (e.g., no timestamps, no PID, etc...).
Desired functionality: There are cases where it would be helpful to supply a custom prefix to the log messages written either by the user (e.g.,
bn.log.log()
) or by Binja's core lib.Here are a couple of approaches for your consideration: