Set Appkey issued from Log & Crash Search as ProjectKey.
...
#include "NHNCloudLogger.h"
nhncloud::logger::NHNCloudLogger* g_nhncloud_lnc = nullptr; // NHN Cloud SDK - Log & crash search
...
// Assign the NHN Cloud SDK instance to a global variable.
g_nhncloud_lnc = nhncloud::logger::NHNCloudLogger::GetInstance();
// When initializing NHNCloudLogger, input necessary configuration information.
nhncloud::logger::NHNCloudLoggerConfiguration* loggerConf = nhncloud::logger::NHNCloudLoggerConfiguration::GetInstance();
...
// Input the Appkey you checked in the Log & Crash Search console.
loggerConf->setProjectKey(appkey);
// Input the version information of the current application. The version information must match the version
loggerConf->setProjectVersion(version);
...
if (!g_nhncloud_lnc->initialize(loggerConf))
{
// Initialization failure occurs if it has already been initialized or if the AppKey is not inputted.
::MessageBox(g_mainWnd, _T("Failed to initialize NHN Cloud SDK."), _T("Alert"), MB_OK);
return false;
}
User ID can be set for NHN Cloud SDK. Such set UserID is common for each module of NHN Cloud SDK. Set User ID is sent to server, along with logs, every time Log Sending API is called.
nhncloud::logger::NHNCloudLogger* pLogger = nhncloud::logger::NHNCloudLogger::GetInstance();
pLogger->setUserId(pUserID);
pLogger->getUserId();
NHN Cloud Logger provides log sending functions of five levels.
void debug(const wchar_t* message, NHNCloudLoggerUserFields* userFields = NULL);
void info(const wchar_t* message, NHNCloudLoggerUserFields* userFields = NULL);
void warn(const wchar_t* message, NHNCloudLoggerUserFields* userFields = NULL);
void error(const wchar_t* message, NHNCloudLoggerUserFields* userFields = NULL);
void fatal(const wchar_t* message, NHNCloudLoggerUserFields* userFields = NULL);
void log(NHNCLOUD_LOGGER_LEVEL logLevel, const char* message, NHNCloudLoggerUserFields* userFields = nullptr);
bool addUserField(const char* key, const wchar_t* value);
void removeUserField(const char* key);
void clearUserFileds();
...
g_nhncloud_lnc->addUserField("nickname", "randy");
g_nhncloud_lnc->removeUserField("nickname");
g_nhncloud_lnc->cleareUserField();
nhncloud::logger::NHNCloudLoggerUserFields* pUserFieldHelper = nhncloud::logger::NHNCloudLoggerUserFields::GetInstance(); // Get the custom field helper class.
pUserFieldHelper->insert("userCustomKeyHelper01", L"NHNCloudLoggerUserFields 헬퍼 클래스로 추가한 사용자 정의 필드\r\nCustom fields added with the NHNCloudLoggerUserFields helper class");
pUserFieldHelper->insert("userCustomKeyHelper02", L"clear() 함수로 지금껏 정의한 사용자 필드를 간단히 정리할 수 있어요.\r\nWith the clear() function, you can simply clear the custom fields you have defined so far.");
pUserFieldHelper->insert("userCustomKeyHelper03", L"log() 함수로 전송시, NHNCloudLoggerUserFields 클래스에 정의한 사용자 필드들은 로그 객체에 복사됩니다.\r\nWhen sending to the log() function, the user fields defined in the NHNCloudLoggerUserFields class are copied to the log object.");
g_nhncloud_lnc->log(level, pLogMessage, pUserFieldHelper); // Send log with user-defined fields.
pUserFieldHelper->clear(); // Delete all user-defined fields configured above.
#include "NHNCloudLogger.h"
nhncloud::logger::NHNCloudLogger* g_nhncloud_lnc = nullptr; // NHN Cloud SDK - Log & crash search
...
// Assign the NHN Cloud SDK instance to a global variable.
g_nhncloud_lnc = nhncloud::logger::NHNCloudLogger::GetInstance();
// When initializing NHNCloudLogger, input necessary configuration information.
nhncloud::logger::NHNCloudLoggerConfiguration* loggerConf = nhncloud::logger::NHNCloudLoggerConfiguration::GetInstance();
...
// Input the AppKey you checked in the Log & Crash Search console.
loggerConf->setProjectKey(appkey);
// Input the version information of the current application. The version information must match the version information inputted during the symbol file registration.
loggerConf->setProjectVersion(version);
// Enable Crash Collection - This is enabled by default. Set to false if you don't want crash collection.
loggerConf->enableCrashReporter(true);
// To use Crash Reporter (CrashReporter.exe) running as a separate process, set enableSilenceMode(false).
loggerConf->enableSilenceMode(false);
// Defines the message to be exposed to the CrashReporter running as a separate process. If not defined, the default message will be shown.
loggerConf->setCrashReporterMessage(NHNCLOUD_LANGUAGE_KOREAN, "An error has occurred...\n");
// If you want to send the crash as a separate process, but do not want to expose the UI to the user, set exposeExternalCrashReporterUI(false).
//loggerConf->exposeExternalCrashReporterUI(false);
...
// After initialization is complete, crash collection becomes available.
if (!g_nhncloud_lnc->initialize(loggerConf))
{
// Initialization fails if it has already been initialized, or if no Appkey has been entered.
::MessageBox(g_mainWnd, _T("Failed to initialize NHN Cloud SDK."), _T("Alert"), MB_OK);
return false;
}
void CsampleDlg::OnBnClickedCrash()
{
// TODO: Add your control notification handler code here
int *i = reinterpret_cast<int*>(0x45);
*i = 5;
}
To interpret crashes occurred in NHN Cloud Windows SDK, a symbol file must be created and uploaded to a web console.
nhncloudsdk_example
example project in the distribution file path.dump_syms sample.pdb > sample.sym