Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,4 +1900,53 @@ void EngineDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("send_message", "message", "data"), &EngineDebugger::send_message);
}

////// LogManager //////
// This is the client-facing part of the user log hooking system.
// It's basically just a shunt that passes callbacks to the persistent UserLogManagerLogger singleton.

LogManager *LogManager::singleton = nullptr;

LogManager::LogManager() {
ERR_FAIL_COND_MSG(singleton != nullptr, "Somehow created two LogManagers.");

singleton = this;
}

LogManager::~LogManager() {
ERR_FAIL_COND_MSG(singleton != this, "LogManager::singleton not correct on exit.");

singleton = nullptr;
}

void LogManager::register_log_capture_non_thread_safe(const Callable &p_callable) {
UserLogManagerLogger *log_manager = UserLogManagerLogger::get_singleton();
ERR_FAIL_NULL_MSG(log_manager, "log_manager not yet initialized. This shouldn't be possible.");
log_manager->register_log_capture_non_thread_safe(p_callable);
}

void LogManager::unregister_log_capture_non_thread_safe(const Callable &p_callable) {
UserLogManagerLogger *log_manager = UserLogManagerLogger::get_singleton();
ERR_FAIL_NULL_MSG(log_manager, "log_manager not yet initialized. This shouldn't be possible.");
log_manager->unregister_log_capture_non_thread_safe(p_callable);
}

void LogManager::register_log_capture_buffered(const Callable &p_callable) {
UserLogManagerLogger *log_manager = UserLogManagerLogger::get_singleton();
ERR_FAIL_NULL_MSG(log_manager, "log_manager not yet initialized. This shouldn't be possible.");
log_manager->register_log_capture_buffered(p_callable);
}

void LogManager::unregister_log_capture_buffered(const Callable &p_callable) {
UserLogManagerLogger *log_manager = UserLogManagerLogger::get_singleton();
ERR_FAIL_NULL_MSG(log_manager, "log_manager not yet initialized. This shouldn't be possible.");
log_manager->unregister_log_capture_buffered(p_callable);
}

void LogManager::_bind_methods() {
ClassDB::bind_method(D_METHOD("register_log_capture_non_thread_safe", "callable"), &LogManager::register_log_capture_non_thread_safe);
ClassDB::bind_method(D_METHOD("unregister_log_capture_non_thread_safe", "callable"), &LogManager::unregister_log_capture_non_thread_safe);
ClassDB::bind_method(D_METHOD("register_log_capture_buffered", "callable"), &LogManager::register_log_capture_buffered);
ClassDB::bind_method(D_METHOD("unregister_log_capture_buffered", "callable"), &LogManager::unregister_log_capture_buffered);
}

} // namespace core_bind
20 changes: 20 additions & 0 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,26 @@ class EngineDebugger : public Object {
~EngineDebugger();
};

class LogManager : public Object {
GDCLASS(LogManager, Object);

protected:
static void _bind_methods();
static LogManager *singleton;

public:
LogManager();
~LogManager();

static LogManager *get_singleton() { return singleton; }

void register_log_capture_non_thread_safe(const Callable &p_callable);
void unregister_log_capture_non_thread_safe(const Callable &p_callable);

void register_log_capture_buffered(const Callable &p_callable);
void unregister_log_capture_buffered(const Callable &p_callable);
};

} // namespace core_bind

VARIANT_ENUM_CAST(core_bind::ResourceLoader::ThreadLoadStatus);
Expand Down
Loading