Skip to content

Commit 6b5e7d2

Browse files
committed
make sure the length of the short build hash stays below 8 characters
1 parent feb55a1 commit 6b5e7d2

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

IntelPresentMon/CommonUtilities/log/Log.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ namespace pmon::util::log
3434
#endif
3535
#endif
3636

37-
#define pmlog_(lvl) ((PMLOG_BUILD_LEVEL_ < lvl) || (::pmon::util::log::GlobalPolicy::Get().GetLogLevel() < lvl)) \
38-
? (void)0 : ::pmon::util::log::Voidifier_{} & ::pmon::util::log::EntryBuilder{ lvl, __FILE__, __FUNCTION__, __LINE__ } \
37+
#define pmlog_from_(lvl, file, function, line) ((PMLOG_BUILD_LEVEL_ < lvl) || (::pmon::util::log::GlobalPolicy::Get().GetLogLevel() < lvl)) \
38+
? (void)0 : ::pmon::util::log::Voidifier_{} & ::pmon::util::log::EntryBuilder{ lvl, file, function, line } \
3939
.subsys(::pmon::util::log::GlobalPolicy::Get().GetSubsystem()) \
4040
.to(::pmon::util::log::GetDefaultChannel())
41+
#define pmlog_(lvl) pmlog_from_(lvl, __FILE__, __FUNCTION__, __LINE__)
4142
#define pmlog_fatal pmlog_(::pmon::util::log::Level::Fatal).note
4243
#define pmlog_error pmlog_(::pmon::util::log::Level::Error).note
4344
#define pmlog_warn pmlog_(::pmon::util::log::Level::Warning).note

IntelPresentMon/Core/source/infra/LogSetup.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,41 @@ namespace p2c
7373
using namespace pmon::util;
7474
using namespace pmon::util::log;
7575

76+
_invalid_parameter_handler pOriginalInvalidParameterHandler_ = nullptr;
77+
78+
namespace {
79+
void InvalidParameterHandler_(
80+
const wchar_t* expression,
81+
const wchar_t* function,
82+
const wchar_t* file,
83+
unsigned int line,
84+
uintptr_t pReserved)
85+
{
86+
// convert to narrow and log the assertion content
87+
const auto narrowFunction = str::ToNarrow(function);
88+
const auto narrowFile = str::ToNarrow(file);
89+
pmlog_from_(Level::Fatal, narrowFile.c_str(), narrowFunction.c_str(), (int)line)
90+
.note(std::format("CRT assertion: {}", str::ToNarrow(expression)));
91+
// flush the default channel
92+
if (auto pChan = GetDefaultChannel()) {
93+
pChan->Flush();
94+
}
95+
// invoke the original handler
96+
if (pOriginalInvalidParameterHandler_) {
97+
pOriginalInvalidParameterHandler_(expression, function, file, line, pReserved);
98+
}
99+
}
100+
}
101+
76102
void ConfigureLogging() noexcept
77103
{
78104
try {
79105
auto pChan = GetDefaultChannel();
106+
// setup CRT assert handler
107+
pOriginalInvalidParameterHandler_ = _set_invalid_parameter_handler(InvalidParameterHandler_);
80108
// shortcut for command line
81109
const auto& opt = cli::Options::Get();
82110
const auto render = opt.cefType && *opt.cefType == "renderer";
83-
// connect dll channel and id table to exe, get access to global settings in dll
84-
LoggingSingletons getters;
85-
if (render && opt.logMiddlewareCopy) {
86-
getters = pmLinkLogging_(pChan, []() -> IdentificationTable& {
87-
return IdentificationTable::Get_(); });
88-
}
89111

90112
// determine log folder path
91113
std::filesystem::path logFolder;
@@ -103,6 +125,12 @@ namespace p2c
103125
pChan->AttachComponent(std::make_shared<BasicFileDriver>(std::make_shared<TextFormatter>(),
104126
std::make_shared<SimpleFileStrategy>(logfilePathClient)), "drv:file");
105127
auto&& pol = GlobalPolicy::Get();
128+
// connect dll channel and id table to exe, get access to global settings in dll
129+
LoggingSingletons getters;
130+
if (render && opt.logMiddlewareCopy) {
131+
getters = pmLinkLogging_(pChan, []() -> IdentificationTable& {
132+
return IdentificationTable::Get_(); });
133+
}
106134
// set the global policy settings
107135
if (opt.logLevel) {
108136
pol.SetLogLevel(*opt.logLevel);

IntelPresentMon/Versioning/scripts/pre-build.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ Write-Host "[build_id_gen] Generating new build_id.h..."
117117

118118
# Get the current git commit hash
119119
$gitHash = (git rev-parse HEAD) | Out-String
120-
$gitHashShort = (git rev-parse --short HEAD)| Out-String
121120
$gitHash = $gitHash.Trim()
122-
$gitHashShort = $gitHashShort.Trim()
121+
$gitHashShort = $gitHash.Substring(0, 7)
123122

124123
# Format: yyyy.M.d.HH:mm:ss (e.g., 2025.1.8.12:20:11)
125124
$dateTime = Get-Date -Format 'yyyy.M.d.HH:mm:ss'

0 commit comments

Comments
 (0)