summaryrefslogtreecommitdiff
path: root/bin/bbackupd/Win32ServiceFunctions.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-07-31 23:18:05 +0000
committerChris Wilson <chris+github@qwirx.com>2007-07-31 23:18:05 +0000
commit0b2fd98dd63c533e00c0d61ce022f37ee75857cc (patch)
tree5daa2a50b28b572e01281b622fee3adf818f5075 /bin/bbackupd/Win32ServiceFunctions.cpp
parent05db569d4efc62eaa10597142b8eac4937421e14 (diff)
Replace almost all calls to syslog() with logging framework. (refs #3)
Diffstat (limited to 'bin/bbackupd/Win32ServiceFunctions.cpp')
-rw-r--r--bin/bbackupd/Win32ServiceFunctions.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/bin/bbackupd/Win32ServiceFunctions.cpp b/bin/bbackupd/Win32ServiceFunctions.cpp
index 3010cf3f..f4c8894b 100644
--- a/bin/bbackupd/Win32ServiceFunctions.cpp
+++ b/bin/bbackupd/Win32ServiceFunctions.cpp
@@ -44,7 +44,7 @@ void ErrorHandler(char *s, DWORD err)
char buf[256];
memset(buf, 0, sizeof(buf));
_snprintf(buf, sizeof(buf)-1, "%s (%d)", s, err);
- ::syslog(LOG_ERR, "%s", buf);
+ BOX_ERROR(buf);
MessageBox(0, buf, "Error",
MB_OK | MB_SETFOREGROUND | MB_DEFAULT_DESKTOP_ONLY);
ExitProcess(err);
@@ -191,16 +191,16 @@ int InstallService(const char* pConfigFileName)
if (emu_stat(pConfigFileName, &st) != 0)
{
- syslog(LOG_ERR, "Failed to open configuration file: "
- "%s: %s", pConfigFileName, strerror(errno));
+ BOX_ERROR("Failed to open configuration file '" <<
+ pConfigFileName << "': " << strerror(errno));
return 1;
}
if (!(st.st_mode & S_IFREG))
{
- syslog(LOG_ERR, "Failed to open configuration file: "
- "%s: not a file", pConfigFileName);
+ BOX_ERROR("Failed to open configuration file '" <<
+ pConfigFileName << "': not a file");
return 1;
}
}
@@ -209,8 +209,8 @@ int InstallService(const char* pConfigFileName)
if (!scm)
{
- syslog(LOG_ERR, "Failed to open service control manager: "
- "error %d", GetLastError());
+ BOX_ERROR("Failed to open service control manager: " <<
+ GetErrorMessage(GetLastError()));
return 1;
}
@@ -248,21 +248,21 @@ int InstallService(const char* pConfigFileName)
{
case ERROR_SERVICE_EXISTS:
{
- ::syslog(LOG_ERR, "Failed to create Box Backup "
+ BOX_ERROR("Failed to create Box Backup "
"service: it already exists");
}
break;
case ERROR_SERVICE_MARKED_FOR_DELETE:
{
- ::syslog(LOG_ERR, "Failed to create Box Backup "
+ BOX_ERROR("Failed to create Box Backup "
"service: it is waiting to be deleted");
}
break;
case ERROR_DUPLICATE_SERVICE_NAME:
{
- ::syslog(LOG_ERR, "Failed to create Box Backup "
+ BOX_ERROR("Failed to create Box Backup "
"service: a service with this name "
"already exists");
}
@@ -270,15 +270,16 @@ int InstallService(const char* pConfigFileName)
default:
{
- ::syslog(LOG_ERR, "Failed to create Box Backup "
- "service: error %d", err);
+ BOX_ERROR("Failed to create Box Backup "
+ "service: error " <<
+ GetErrorMessage(GetLastError()));
}
}
return 1;
}
- ::syslog(LOG_INFO, "Created Box Backup service");
+ BOX_INFO("Created Box Backup service");
SERVICE_DESCRIPTION desc;
desc.lpDescription = "Backs up your data files over the Internet";
@@ -286,8 +287,8 @@ int InstallService(const char* pConfigFileName)
if (!ChangeServiceConfig2(newService, SERVICE_CONFIG_DESCRIPTION,
&desc))
{
- ::syslog(LOG_WARNING, "Failed to set description for "
- "Box Backup service: error %d", GetLastError());
+ BOX_WARNING("Failed to set description for Box Backup "
+ "service: " << GetErrorMessage(GetLastError()));
}
CloseServiceHandle(newService);
@@ -301,8 +302,8 @@ int RemoveService(void)
if (!scm)
{
- syslog(LOG_ERR, "Failed to open service control manager: "
- "error %d", GetLastError());
+ BOX_ERROR("Failed to open service control manager: " <<
+ GetErrorMessage(GetLastError()));
return 1;
}
@@ -317,13 +318,13 @@ int RemoveService(void)
err == ERROR_IO_PENDING)
// hello microsoft? anyone home?
{
- syslog(LOG_ERR, "Failed to open Box Backup service: "
+ BOX_ERROR("Failed to open Box Backup service: "
"not installed or not found");
}
else
{
- syslog(LOG_ERR, "Failed to open Box Backup service: "
- "error %d", err);
+ BOX_ERROR("Failed to open Box Backup service: " <<
+ GetErrorMessage(err));
}
return 1;
}
@@ -334,8 +335,8 @@ int RemoveService(void)
err = GetLastError();
if (err != ERROR_SERVICE_NOT_ACTIVE)
{
- syslog(LOG_WARNING, "Failed to stop Box Backup "
- "service: error %d", err);
+ BOX_WARNING("Failed to stop Box Backup service: " <<
+ GetErrorMessage(err));
}
}
@@ -345,18 +346,18 @@ int RemoveService(void)
if (deleted)
{
- syslog(LOG_INFO, "Box Backup service deleted");
+ BOX_INFO("Box Backup service deleted");
return 0;
}
else if (err == ERROR_SERVICE_MARKED_FOR_DELETE)
{
- syslog(LOG_ERR, "Failed to remove Box Backup service: "
+ BOX_ERROR("Failed to remove Box Backup service: "
"it is already being deleted");
}
else
{
- syslog(LOG_ERR, "Failed to remove Box Backup service: "
- "error %d", err);
+ BOX_ERROR("Failed to remove Box Backup service: " <<
+ GetErrorMessage(err));
}
return 1;