Skip to content

Commit 8f633b2

Browse files
Merge pull request #518 from GameTechDev/feature/verbose2
Feature/verbose2
2 parents 0dd1145 + e1700ca commit 8f633b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+265
-196
lines changed

IntelPresentMon/AppCef/source/NanoCefProcessHandler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
using namespace pmon::util;
1919
using namespace std::chrono_literals;
20+
namespace rn = std::ranges;
21+
namespace vi = std::views;
2022

2123
namespace p2c::client::cef
2224
{
@@ -86,6 +88,12 @@ namespace p2c::client::cef
8688
pChildCommandLine->AppendSwitchWithValue(std::move(name), std::move(val));
8789
}
8890
}
91+
// special handling or CLI options that are vectors with map transformer (verbose modules)
92+
// TODO: figure out how to get this special case working with the auto forwarding mechanism
93+
for (auto mod : *opt.logVerboseModules) {
94+
pChildCommandLine->AppendSwitchWithValue(opt.logVerboseModules.GetName(),
95+
log::GetVerboseModuleName(mod));
96+
}
8997
// initiate logging ipc connection for renderer children
9098
if (pChildCommandLine->GetSwitchValue("type") == "renderer") {
9199
// inject logging ipc pipe cli option to child

IntelPresentMon/AppCef/source/util/AsyncEndpointManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#include <include/base/cef_callback.h>
99
#include <include/wrapper/cef_closure_task.h>
1010
#include <include/wrapper/cef_helpers.h>
11-
#include "CefValues.h"
1211
#include <CommonUtilities\str\String.h>
1312

1413

1514
namespace p2c::client::util
1615
{
1716
using ::pmon::util::str::ToWide;
17+
using v = log::V;
1818

1919
void AsyncEndpointManager::DispatchInvocation(const std::string& key, CallbackContext ctx, CefRefPtr<CefV8Value> pObj, CefBrowser& browser, cef::DataBindAccessor& accessor)
2020
{
@@ -30,8 +30,8 @@ namespace p2c::client::util
3030
);
3131
lck.unlock();
3232

33-
if constexpr (v::v8async) {
34-
pmlog_verb(v::v8async)(std::format("JS async call {{{}}} from V8 to endpoint [{}] with payload:\n{}",
33+
if (log::GlobalPolicy::VCheck(v::v8async)) {
34+
pmlog_(log::Level::Verbose).note(std::format("JS async call {{{}}} from V8 to endpoint [{}] with payload:\n{}",
3535
uid, key, Traverse(V8ToCefValue(*pObj)).Dump()));
3636
}
3737
else {
@@ -88,12 +88,12 @@ namespace p2c::client::util
8888
{
8989
auto invocation = std::move(i->second);
9090

91-
if constexpr (v::v8async) {
92-
pmlog_verb(v::v8async)(std::format("Async call {{{}}} resolved with payload: \n{}",
91+
if (log::GlobalPolicy::VCheck(v::v8async)) {
92+
pmlog_(log::Level::Verbose).note(std::format("Async call {{{}}} resolved with payload: \n{}",
9393
uid, Traverse(pArgs).Dump()));
9494
}
9595
else {
96-
pmlog_verb(v::v8async)(std::format("Async call {{{}}} resolved", uid));
96+
pmlog_dbg(std::format("Async call {{{}}} resolved", uid));
9797
}
9898

9999
invocations.erase(i);

IntelPresentMon/AppCef/source/util/CliOptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace p2c::client::util::cli
1010
{
1111
private:
1212
CLI::CheckedTransformer logLevelTf_{ log::GetLevelMapNarrow(), CLI::ignore_case };
13+
CLI::CheckedTransformer logVmodTf_{ log::GetVerboseModuleMapNarrow(), CLI::ignore_case };
1314

1415
private: Group gd_{ this, "Debugging", "Aids in debugging this tool" }; public:
1516
Option<std::string> url{ this, "--p2c-url", "", "URL to load instead of app files" };
@@ -29,6 +30,7 @@ namespace p2c::client::util::cli
2930
Option<std::string> logDenyList{ this, "--p2c-log-deny-list", "", "Path to log deny list (with trace overrides)", CLI::ExistingFile };
3031
Option<std::string> logAllowList{ this, "--p2c-log-allow-list", "", "Path to log allow list (with trace overrides)", CLI::ExistingFile };
3132
Option<std::string> logFolder{ this, "--p2c-log-folder", "", "Path to directory in which to store log files", CLI::ExistingDirectory };
33+
Option<std::vector<log::V>> logVerboseModules{ this, "--p2c-log-verbose-modules", {}, "Verbose logging modules to enable", logVmodTf_ };
3234

3335
private: Group gi_{ this, "Internal", "Internal options, do not supply manually" }; public:
3436
Option<std::string> cefType{ this, "--type", "", "Type of the current chromium process" };
@@ -40,7 +42,7 @@ namespace p2c::client::util::cli
4042

4143
private:
4244
MutualExclusion excl_{ logDenyList, logAllowList };
43-
NoForward noForward_{ cefType, logPipeName };
45+
NoForward noForward_{ cefType, logPipeName, logVerboseModules };
4446
AllowExtras ext_{ this };
4547
};
4648
}

IntelPresentMon/AppCef/source/util/LogSetup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ namespace p2c::client::util
111111
if (opt.logLevel) {
112112
pol.SetLogLevel(*opt.logLevel);
113113
}
114+
if (opt.logVerboseModules) {
115+
for (auto mod : *opt.logVerboseModules) {
116+
pol.ActivateVerboseModule(mod);
117+
}
118+
}
114119
if (opt.logTraceLevel) {
115120
pol.SetTraceLevel(*opt.logTraceLevel);
116121
}
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,2 @@
11
#pragma once
2-
//#define PMLOG_BUILD_LEVEL Verbose
3-
//#define VVV_V8ASYNC
4-
#include <CommonUtilities/log/Log.h>
5-
6-
7-
namespace p2c::v
8-
{
9-
#ifndef VVV_V8ASYNC // system for async calls and signals between V8 and C++
10-
inline constexpr bool v8async = false;
11-
#else
12-
inline constexpr bool v8async = true;
13-
#endif
14-
#ifndef VVV_HOTKEY // system that processes raw keyboard input
15-
inline constexpr bool hotkey = false;
16-
#else
17-
inline constexpr bool hotkey = true;
18-
#endif
19-
}
2+
#include <CommonUtilities/log/Log.h>

IntelPresentMon/CommonUtilities/CommonUtilities.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<ClInclude Include="log\TextFormatter.h" />
6363
<ClInclude Include="log\MarshallDriver.h" />
6464
<ClInclude Include="log\TimePoint.h" />
65+
<ClInclude Include="log\Verbose.h" />
6566
<ClInclude Include="Macro.h" />
6667
<ClInclude Include="Math.h" />
6768
<ClInclude Include="Memory.h" />
@@ -141,6 +142,7 @@
141142
<ClCompile Include="log\MarshallDriver.cpp" />
142143
<ClCompile Include="log\NamedPipeMarshallSender.cpp" />
143144
<ClCompile Include="log\TimePoint.cpp" />
145+
<ClCompile Include="log\Verbose.cpp" />
144146
<ClCompile Include="mt\Thread.cpp" />
145147
<ClCompile Include="pipe\CoroMutex.cpp" />
146148
<ClCompile Include="pipe\Pipe.cpp" />

IntelPresentMon/CommonUtilities/CommonUtilities.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@
279279
<ClInclude Include="rng\OptionalMinMax.h">
280280
<Filter>Header Files</Filter>
281281
</ClInclude>
282+
<ClInclude Include="log\Verbose.h">
283+
<Filter>Header Files</Filter>
284+
</ClInclude>
282285
</ItemGroup>
283286
<ItemGroup>
284287
<ClCompile Include="cli\CliFramework.cpp">
@@ -437,6 +440,9 @@
437440
<ClCompile Include="win\com\WbemSink.cpp">
438441
<Filter>Source Files</Filter>
439442
</ClCompile>
443+
<ClCompile Include="log\Verbose.cpp">
444+
<Filter>Source Files</Filter>
445+
</ClCompile>
440446
</ItemGroup>
441447
<ItemGroup>
442448
<None Include="vcpkg.json" />

IntelPresentMon/CommonUtilities/log/GlobalPolicy.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,24 @@ namespace pmon::util::log
7777
{
7878
subsystem_ = sys;
7979
}
80+
void GlobalPolicy::ActivateVerboseModule(V mod) noexcept
81+
{
82+
activeVerboseModules_ |= (1ull << uint64_t(mod));
83+
}
84+
void GlobalPolicy::DeactivateVerboseModule(V mod) noexcept
85+
{
86+
activeVerboseModules_ &= ~(1ull << uint64_t(mod));
87+
}
88+
bool GlobalPolicy::CheckVerboseModule(V mod) const noexcept
89+
{
90+
return activeVerboseModules_ & (1ull << uint64_t(mod));
91+
}
92+
void GlobalPolicy::ClearVerboseModules() noexcept
93+
{
94+
activeVerboseModules_ = 0;
95+
}
96+
void GlobalPolicy::StoreVerboseModules(uint64_t modset) noexcept
97+
{
98+
activeVerboseModules_.store(modset);
99+
}
80100
}

IntelPresentMon/CommonUtilities/log/GlobalPolicy.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <atomic>
33
#include "Level.h"
44
#include "Subsystem.h"
5+
#include "Verbose.h"
56

67
namespace pmon::util::log
78
{
@@ -22,7 +23,16 @@ namespace pmon::util::log
2223
void SetSehTracing(bool on) noexcept;
2324
Subsystem GetSubsystem() const noexcept;
2425
void SetSubsystem(Subsystem) noexcept;
26+
void ActivateVerboseModule(V mod) noexcept;
27+
void DeactivateVerboseModule(V mod) noexcept;
28+
bool CheckVerboseModule(V mod) const noexcept;
29+
void ClearVerboseModules() noexcept;
30+
void StoreVerboseModules(uint64_t modset) noexcept;
2531
static GlobalPolicy& Get() noexcept;
32+
static bool VCheck(V mod) noexcept
33+
{
34+
return Get().CheckVerboseModule(mod);
35+
}
2636
private:
2737
// functions
2838
GlobalPolicy() noexcept;
@@ -33,5 +43,6 @@ namespace pmon::util::log
3343
std::atomic<bool> exceptionTracePolicy_ = false;
3444
std::atomic<bool> sehTraceOn_ = false;
3545
std::atomic<Subsystem> subsystem_ = Subsystem::None;
46+
std::atomic<uint64_t> activeVerboseModules_ = 0;
3647
};
3748
}

IntelPresentMon/CommonUtilities/log/Level.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace pmon::util::log
1515
case Level::Performance: return "Performance";
1616
case Level::Debug: return "Debug";
1717
case Level::Verbose: return "Verbose";
18+
case Level::Verbose2: return "Verbose2";
1819
default: return "Unknown";
1920
}
2021
} catch (...) {}
@@ -28,7 +29,7 @@ namespace pmon::util::log
2829
for (int n = (int)Level::Fatal; n <= (int)Level::Verbose; n++) {
2930
const auto lvl = Level(n);
3031
auto key = ToLower(GetLevelName(lvl));
31-
if (key != "unknown") {
32+
if (key != "Unknown") {
3233
map[std::move(key)] = lvl;
3334
}
3435
}

0 commit comments

Comments
 (0)