Skip to content

Commit

Permalink
Add log messages to ease debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
dictoon committed Dec 15, 2016
1 parent 37433d9 commit 87ea416
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/appleseed-max/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "main.h"

// 3ds Max headers.
#include <log.h>
#include <max.h>

HINSTANCE g_module;
Expand All @@ -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);
Expand Down
34 changes: 33 additions & 1 deletion src/appleseed-max/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

// 3ds Max headers.
#include <iparamb2.h>
#include <log.h>
#include <max.h>
#include <plugapi.h>

// Windows headers.
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 87ea416

Please sign in to comment.