Skip to content

Commit a891ae0

Browse files
committed
fixing log configuration in cef and option to enable diag for validation
1 parent 765fd55 commit a891ae0

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

IntelPresentMon/AppCef/source/winmain.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <Core/source/cli/CliOptions.h>
1010
#include <CommonUtilities/log/IdentificationTable.h>
1111
#include <CommonUtilities/generated/build_id.h>
12+
#include <PresentMonAPIWrapper/DiagnosticHandler.h>
1213
#include <dwmapi.h>
1314

1415
#pragma comment(lib, "Dwmapi.lib")
@@ -203,8 +204,21 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
203204
DebugBreak();
204205
}
205206
// name this process / thread
206-
log::IdentificationTable::AddThisProcess(str::ToWide(Options::Get().cefType.AsOptional().value_or("main-client")));
207+
log::IdentificationTable::AddThisProcess(str::ToWide(opt.cefType.AsOptional().value_or("main-client")));
207208
log::IdentificationTable::AddThisThread(L"main");
209+
// connect to the diagnostic layer
210+
std::optional<pmapi::DiagnosticHandler> diag;
211+
if (opt.enableDiagnostic && opt.cefType && *opt.cefType == "renderer") {
212+
diag.emplace(
213+
(PM_DIAGNOSTIC_LEVEL)opt.logLevel.AsOptional().value_or(log::GlobalPolicy::Get().GetLogLevel()),
214+
PM_DIAGNOSTIC_OUTPUT_FLAGS_DEBUGGER | PM_DIAGNOSTIC_OUTPUT_FLAGS_QUEUE,
215+
[](const PM_DIAGNOSTIC_MESSAGE& msg) {
216+
auto ts = msg.pTimestamp ? str::ToWide(msg.pTimestamp) : std::wstring{};
217+
pmlog_(log::Level(msg.level)).note(
218+
std::format(L"@@ D I A G @@ => <{}> {}", ts, str::ToWide(msg.pText)));
219+
}
220+
);
221+
}
208222
// configure the logging system (partially based on command line options)
209223
ConfigureLogging();
210224

IntelPresentMon/CommonUtilities/log/Log.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ namespace pmon::util::log
2727
#endif
2828
#endif
2929

30-
#define xinternal_pmlog_(lvl) ((PMLOG_BUILD_LEVEL < lvl) || (::pmon::util::log::GlobalPolicy::Get().GetLogLevel() < lvl)) \
30+
#define pmlog_(lvl) ((PMLOG_BUILD_LEVEL < lvl) || (::pmon::util::log::GlobalPolicy::Get().GetLogLevel() < lvl)) \
3131
? (void)0 : (void)::pmon::util::log::EntryBuilder{ lvl, __FILEW__, __FUNCTIONW__, __LINE__ } \
3232
.subsys(::pmon::util::log::GlobalPolicy::Get().GetSubsystem()) \
3333
.to(::pmon::util::log::GetDefaultChannel())
34-
#define pmlog_fatal xinternal_pmlog_(::pmon::util::log::Level::Fatal).note
35-
#define pmlog_error xinternal_pmlog_(::pmon::util::log::Level::Error).note
36-
#define pmlog_warn xinternal_pmlog_(::pmon::util::log::Level::Warning).note
37-
#define pmlog_info xinternal_pmlog_(::pmon::util::log::Level::Info).note
38-
#define pmlog_dbg xinternal_pmlog_(::pmon::util::log::Level::Debug).note
39-
#define pmlog_verb(vtag) !vtag ? (void)0 : xinternal_pmlog_(::pmon::util::log::Level::Verbose).note
40-
#define pmlog_perf(ptag) !ptag ? (void)0 : xinternal_pmlog_(::pmon::util::log::Level::Performance).note
34+
#define pmlog_fatal pmlog_(::pmon::util::log::Level::Fatal).note
35+
#define pmlog_error pmlog_(::pmon::util::log::Level::Error).note
36+
#define pmlog_warn pmlog_(::pmon::util::log::Level::Warning).note
37+
#define pmlog_info pmlog_(::pmon::util::log::Level::Info).note
38+
#define pmlog_dbg pmlog_(::pmon::util::log::Level::Debug).note
39+
#define pmlog_verb(vtag) !vtag ? (void)0 : pmlog_(::pmon::util::log::Level::Verbose).note
40+
#define pmlog_perf(ptag) !ptag ? (void)0 : pmlog_(::pmon::util::log::Level::Performance).note
4141

4242
#define pmwatch(expr) watch(L###expr, (expr))
4343

IntelPresentMon/Core/source/cli/CliOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace p2c::cli
2525
Flag debugWaitClient{ this, "--p2c-debug-wait-client", "Force main client process to wait for debugger connection" };
2626
Flag filesWorking{ this, "--p2c-files-working", "Use the working directory for file storage" };
2727
Flag traceExceptions{ this, "--p2c-trace-exceptions", "Add stack trace to all thrown exceptions (including SEH exceptions)" };
28+
Flag enableDiagnostic{ this, "--p2c-enable-diagnostic", "Enable debug diagnostic layer forwarding (duplicates exiisting log entries)" };
2829

2930
private: Group gl_{ this, "Logging", "Customize logging for this tool"}; public:
3031
Option<log::Level> logLevel{ this, "--p2c-log-level", log::Level::Error, "Severity to log at", logLevelTf_ };

IntelPresentMon/Core/source/infra/LogSetup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace p2c
7575
auto pChan = GetDefaultChannel();
7676
// shortcut for command line
7777
const auto& opt = cli::Options::Get();
78-
const auto render = !opt.cefType;
78+
const auto render = opt.cefType && *opt.cefType == "renderer";
7979
// connect dll channel and id table to exe, get access to global settings in dll
8080
LoggingSingletons getters;
8181
if (render) {

0 commit comments

Comments
 (0)