From 87ea4164b3b53561266288322ac5827400cdf692 Mon Sep 17 00:00:00 2001 From: Franz Beaune Date: Thu, 15 Dec 2016 13:47:42 +0100 Subject: [PATCH] Add log messages to ease debugging --- src/appleseed-max/main.cpp | 7 +++++++ src/appleseed-max/plugin.cpp | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/appleseed-max/main.cpp b/src/appleseed-max/main.cpp index 793b253..5a67523 100644 --- a/src/appleseed-max/main.cpp +++ b/src/appleseed-max/main.cpp @@ -30,6 +30,7 @@ #include "main.h" // 3ds Max headers. +#include #include HINSTANCE g_module; @@ -43,6 +44,12 @@ BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/) { if (reason == DLL_PROCESS_ATTACH) { + GetCOREInterface()->Log()->LogEntry( + SYSLOG_DEBUG, + FALSE, + _T("appleseed"), + _T("[appleseed] Entered DllMain().")); + g_module = module; MaxSDK::Util::UseLanguagePackLocale(); DisableThreadLibraryCalls(module); diff --git a/src/appleseed-max/plugin.cpp b/src/appleseed-max/plugin.cpp index a9106d9..1ed0167 100644 --- a/src/appleseed-max/plugin.cpp +++ b/src/appleseed-max/plugin.cpp @@ -34,6 +34,8 @@ // 3ds Max headers. #include +#include +#include #include // Windows headers. @@ -50,12 +52,36 @@ namespace const DWORD path_length = sizeof(path) / sizeof(wchar_t); if (!GetModuleFileName(g_module, path, path_length)) + { + GetCOREInterface()->Log()->LogEntry( + SYSLOG_ERROR, + FALSE, + _T("appleseed"), + _T("[appleseed] GetModuleFileName() failed.")); return false; + } PathCchRemoveFileSpec(path, path_length); PathCchAppend(path, path_length, filename); - return LoadLibrary(path); + GetCOREInterface()->Log()->LogEntry( + SYSLOG_DEBUG, + FALSE, + _T("appleseed"), + _T("[appleseed] Loading %s..."), path); + + auto result = LoadLibrary(path); + + if (result == nullptr) + { + GetCOREInterface()->Log()->LogEntry( + SYSLOG_ERROR, + FALSE, + _T("appleseed"), + _T("[appleseed] Failed to load %s."), path); + } + + return result; } } @@ -94,6 +120,12 @@ extern "C" __declspec(dllexport) int LibInitialize() { + GetCOREInterface()->Log()->LogEntry( + SYSLOG_DEBUG, + FALSE, + _T("appleseed"), + _T("[appleseed] Entered LibInitialize().")); + if (load_relative_library(_T("appleseed.dll")) == nullptr) return FALSE;