@@ -85,10 +85,12 @@ class msi_logger : public nsclient::logging::logger {
8585
8686
8787 void debug (const std::string& module , const char * file, const int line, const std::string& message) {
88+ do_log (" debug: " + message);
8889 }
8990 void trace (const std::string& module , const char * file, const int line, const std::string& message) {
9091 }
9192 void info (const std::string& module , const char * file, const int line, const std::string& message) {
93+ do_log (" info: " + message);
9294 }
9395 void warning (const std::string& module , const char * file, const int line, const std::string& message) {
9496 do_log (" warning: " + message);
@@ -106,9 +108,11 @@ class msi_logger : public nsclient::logging::logger {
106108
107109
108110 void do_log (const std::string data) {
111+
109112 std::wstring str = utf8::cvt<std::wstring>(data);
110113 if (str.empty ())
111114 return ;
115+ h->setProperty (L" NSCP_ERROR_LOG" , L" Error: " + str);
112116 if (boost::algorithm::starts_with (str, L" error:" )) {
113117 if (!error_.empty ())
114118 error_ += L" \n " ;
@@ -150,7 +154,7 @@ class msi_logger : public nsclient::logging::logger {
150154
151155
152156void nsclient::logging::log_message_factory::log_fatal (std::string message) {
153- // std::cout << message << "\n";
157+ // std::cout << message << "\n";
154158}
155159
156160std::string nsclient::logging::log_message_factory::create_critical (const std::string &module , const char * file, const int line, const std::string &message) {
@@ -318,6 +322,8 @@ std::wstring read_map_data(msi_helper &h) {
318322#define KEY_CONF_OLD_ERROR KEY CONF_OLD_ERROR
319323#define KEY_CONF_HAS_ERRORS KEY CONF_HAS_ERRORS
320324
325+ #define ERROR_KEY L" NSCP_ERROR"
326+
321327
322328void dump_config (msi_helper &h, std::wstring title) {
323329 h.dumpReason (title);
@@ -446,6 +452,7 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
446452
447453 std::wstring map_data = read_map_data (h);
448454 if (allow == L" 0" ) {
455+ h.setProperty (ERROR_KEY, L" Configuration is not allowed to change" );
449456 h.logMessage (L" Configuration not allowed: " + allow);
450457 h.setProperty (KEY_CONF_CAN_CHANGE, L" 0" );
451458 h.setProperty (KEY_CONF_HAS_ERRORS, L" 0" );
@@ -454,7 +461,8 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
454461 }
455462
456463 if (!boost::filesystem::is_directory (utf8::cvt<std::string>(target))) {
457- h.logMessage (L" Target folder not found: " + target);
464+ h.setProperty (ERROR_KEY, L" Configuration not found: " + target);
465+ h.logMessage (L" Target folder not found: " + target);
458466 h.setProperty (KEY_CONF_CAN_CHANGE, L" 1" );
459467 h.setProperty (KEY_CONF_HAS_ERRORS, L" 0" );
460468 dump_config (h, L" After ImportConfig" );
@@ -463,6 +471,7 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
463471
464472 installer_settings_provider provider (&h, target, map_data);
465473 if (!settings_manager::init_installer_settings (&provider, " " )) {
474+ h.setProperty (ERROR_KEY, L" Settings context had fatal errors" );
466475 h.logMessage (L" Settings context had fatal errors" );
467476 h.setProperty (KEY_CONF_OLD_ERROR, provider.get_error ());
468477 h.setProperty (KEY_CONF_CAN_CHANGE, L" 0" );
@@ -554,12 +563,14 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
554563 dump_config (h, L" After ImportConfig" );
555564
556565 } catch (installer_exception e) {
566+ h.setProperty (ERROR_KEY, L" Installer exception" );
557567 h.logMessage (L" Failed to read old configuration file: " + e.what ());
558568 h.setProperty (KEY_CONF_OLD_ERROR, e.what ());
559569 h.setProperty (KEY_CONF_CAN_CHANGE, L" 0" );
560570 h.setProperty (KEY_CONF_HAS_ERRORS, L" 1" );
561571 return ERROR_SUCCESS;
562572 } catch (...) {
573+ h.setProperty (ERROR_KEY, L" Unknown exception" );
563574 h.logMessage (L" Failed to read old configuration file: Unknown exception" );
564575 h.setProperty (KEY_CONF_OLD_ERROR, L" Unknown exception!" );
565576 h.setProperty (KEY_CONF_CAN_CHANGE, L" 0" );
0 commit comments