mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-22 11:51:09 +00:00
Remove duplicated code for getting the ID of the current process in Log.cpp.
Re-use the existing function from ProcessUtils
This commit is contained in:
parent
7b29c29d85
commit
52fdee5a75
1 changed files with 2 additions and 29 deletions
31
src/Log.cpp
31
src/Log.cpp
|
@ -2,40 +2,13 @@
|
|||
|
||||
#include "Platform.h"
|
||||
#include "StringUtils.h"
|
||||
#include "ProcessUtils.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
Log m_globalLog;
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
pid_t currentProcessId = 0;
|
||||
pid_t processId()
|
||||
{
|
||||
if (currentProcessId == 0)
|
||||
{
|
||||
currentProcessId = getpid();
|
||||
}
|
||||
return currentProcessId;
|
||||
}
|
||||
#else
|
||||
DWORD currentProcessId = 0;
|
||||
DWORD processId()
|
||||
{
|
||||
if (currentProcessId == 0)
|
||||
{
|
||||
currentProcessId = GetCurrentProcessId();
|
||||
}
|
||||
return currentProcessId;
|
||||
}
|
||||
#endif
|
||||
|
||||
Log* Log::instance()
|
||||
{
|
||||
return &m_globalLog;
|
||||
|
@ -68,7 +41,7 @@ void Log::writeToStream(std::ostream& stream, Type type, const char* text)
|
|||
stream << "ERROR ";
|
||||
break;
|
||||
}
|
||||
stream << '(' << intToStr(processId()) << ") " << text << std::endl;
|
||||
stream << '(' << intToStr(ProcessUtils::currentProcessId()) << ") " << text << std::endl;
|
||||
}
|
||||
|
||||
void Log::write(Type type, const char* text)
|
||||
|
|
Loading…
Reference in a new issue