Chrysalis - Logging Test Coverage


logging/
File: logging/src/BaseConsoleUser.cpp
Date: 2026-08-27 18:35:06
Lines:
2/2
100.0%
Functions:
1/1
100.0%
Branches:
0/0
-%
Decisions:
0/0
-%
Calls:
0/0
-%

Line Branch Decision Call Exec Source
1 #include "BaseConsoleUser.h"
2
3 #include <cstdio>
4 #ifdef _WIN32
5 #include "Windows.h"
6 #endif
7
8 using namespace Logging;
9
10 3 BaseConsoleUser::BaseConsoleUser() {
11 #ifdef _WIN32
12 const bool attached = AttachConsole(ATTACH_PARENT_PROCESS);
13 if (const bool allocated = !attached && AllocConsole(); attached || allocated) {
14 FILE* f = nullptr;
15 freopen_s(&f, "CONOUT$", "w", stdout);
16 freopen_s(&f, "CONOUT$", "w", stderr);
17 }
18
19 SetConsoleCP(CP_UTF8);
20 SetConsoleOutputCP(CP_UTF8);
21
22 auto enableVT = [](const DWORD stdHandle)
23 {
24 const HANDLE h = GetStdHandle(stdHandle);
25 if (h == INVALID_HANDLE_VALUE) return;
26 DWORD mode = 0;
27 if (GetConsoleMode(h, &mode)) SetConsoleMode(h, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
28 };
29 enableVT(STD_OUTPUT_HANDLE);
30 enableVT(STD_ERROR_HANDLE);
31 #endif
32 3 }
33