20#include "../utils/stringtools.hpp"
37 BOOL bIsWow64 =
false;
44 GetModuleHandle(TEXT(
"kernel32")),
"IsWow64Process");
46 if (NULL != fnIsWow64Process)
48 if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
53 return (
bool)bIsWow64;
105 m_logFile.open(sLogFile, std::ios_base::out | std::ios_base::app | std::ios_base::ate);
211 push_info(
"SESSION WAS TERMINATED SUCCESSFULLY\n");
244 for (
size_t i = 0; i <
m_buffer.size(); i++)
296 OSVERSIONINFOA _osversioninfo;
297 _osversioninfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOA);
298 GetVersionExA(&_osversioninfo);
301 sysInfo =
"OS: Windows v " +
toString((
int)_osversioninfo.dwMajorVersion) +
"." +
toString((
int)_osversioninfo.dwMinorVersion) +
"." +
toString((
int)_osversioninfo.dwBuildNumber) + (
IsWow64() ?
" (64 Bit)" :
"");
334 sLevel +=
"CMDLINE: ";
337 sLevel +=
"WARNING: ";
This class is a specialisation of the Logger to run detached, i.e. as a global instance usable form e...
bool is_buffering() const
Determine, whether this instance is currently buffering or directly writing to a file.
void push_info(const std::string &sInfo)
Push a message to the logger, which is not dependend on the logging level and will be shown without a...
bool open(const std::string &sLogFile)
Open the log file and push the buffered messages directly to this file.
void push_line(Logger::LogLevel lvl, const std::string &sMessage)
Push a message with the corresponding logging level to the logger. The message will be prefixed with ...
std::vector< std::string > m_buffer
~DetachedLogger()
DetachedLogger destructor. Appends a terminating message to the current logfile (if any).
DetachedLogger(Logger::LogLevel lvl=Logger::LVL_INFO)
DetachedLogger constructor. Sets the default logging level.
void setLoggingLevel(Logger::LogLevel lvl)
Change the logging level or completely disable the logger.
void write_system_information()
A helper function to write the current OS's information to the log file.
bool ensure_open()
Ensures that the stream is open and tries to re-open it otherwise.
void push(const std::string &sMessage)
Push a message to the logger stream. Will automatically re-open a file, if the stream had been closed...
bool is_open() const
Check, whether the logger stream is currently open.
void push_line(const std::string &sMessage)
Push a line to the logger stream. The stream will automatically append the line termination character...
bool open(const std::string &sLogFile)
Open the target logging file for writing.
Logger()
Empty default constructor.
void close()
Close the logger stream.
bool IsWow64()
This function returns true, if we're currently running on Win x64.
BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE, PBOOL)
std::string toString(int)
Converts an integer to a string without the Settings bloat.