Skip to content

Commit 51d0cdf

Browse files
committed
Move middleware file logging to internal for the time being
1 parent 7d28b20 commit 51d0cdf

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

IntelPresentMon/Core/source/infra/LogSetup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ namespace p2c
166166
}
167167
// enable logfile for middleware if we're not doing the copy connection
168168
if (!opt.logMiddlewareCopy && *opt.cefType == "renderer") {
169-
if (auto sta = pmSetupFileLogging(logFolder.string().c_str(),
169+
if (auto sta = pmSetupFileLogging_((logFolder / "pmlog-mid.txt").string().c_str(),
170170
(PM_DIAGNOSTIC_LEVEL)pol.GetLogLevel(),
171171
(PM_DIAGNOSTIC_LEVEL)pol.GetTraceLevel(),
172172
pol.GetExceptionTrace()

IntelPresentMon/PresentMonAPI2/Internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ PRESENTMON_API2_EXPORT void pmFlushEntryPoint_() noexcept;
3434
// set middleware to log using OutputDebugString
3535
PRESENTMON_API2_EXPORT void pmSetupODSLogging_(PM_DIAGNOSTIC_LEVEL logLevel,
3636
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace);
37+
38+
// configure the middleware to log to a file (independent of and exclusive to diagnostic system)
39+
// path: path to the folder to where the logfile will be written (set NULL to disable file logging)
40+
// logLevel: only log entries at or above this severity
41+
// stackTraceLevel: only add stacktraces to entries at or above this level
42+
// exceptionTrace: capture additional stacktrace at point of throwing of exceptions
43+
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging_(const char* filename, PM_DIAGNOSTIC_LEVEL logLevel,
44+
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace);

IntelPresentMon/PresentMonAPI2/PresentMonDiagnostics.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,14 @@ PRESENTMON_API2_EXPORT PM_STATUS pmDiagnosticUnblockWaitingThread()
127127
return PM_STATUS_FAILURE;
128128
}
129129

130-
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging(const char* path, PM_DIAGNOSTIC_LEVEL logLevel,
130+
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging_(const char* filename, PM_DIAGNOSTIC_LEVEL logLevel,
131131
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace)
132132
{
133-
const auto fsPath = std::filesystem::path(path);
134-
if (!std::filesystem::is_directory(fsPath)) {
133+
auto filePath = std::filesystem::path(filename);
134+
if (!std::filesystem::is_directory(filePath.parent_path())) {
135135
return PM_STATUS_NONEXISTENT_FILE_PATH;
136136
}
137-
auto file = fsPath / std::format("pmlog-mid-{}.txt", GetCurrentProcessId());
138-
log::SetupFileChannel(std::move(file), GetLogLevel_(logLevel),
137+
log::SetupFileChannel(std::move(filePath), GetLogLevel_(logLevel),
139138
GetLogLevel_(stackTraceLevel), exceptionTrace);
140139
return PM_STATUS_SUCCESS;
141140
}

IntelPresentMon/PresentMonAPI2/PresentMonDiagnostics.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,6 @@ extern "C" {
119119
// wake it up so that it can exit gracefully
120120
PRESENTMON_API2_EXPORT PM_STATUS pmDiagnosticUnblockWaitingThread();
121121

122-
// configure the middleware to log to a file (independent of diagnostic system)
123-
// path: path to the folder to where the logfile will be written (set NULL to disable file logging)
124-
// logLevel: only log entries at or above this severity
125-
// stackTraceLevel: only add stacktraces to entries at or above this level
126-
// exceptionTrace: capture additional stacktrace at point of throwing of exceptions
127-
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging(const char* path, PM_DIAGNOSTIC_LEVEL logLevel,
128-
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace);
129-
130-
131122
#ifdef __cplusplus
132123
} // extern "C"
133124
#endif

IntelPresentMon/PresentMonAPI2Loader/Implementation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ PM_STATUS(*pFunc_pmDiagnosticEnqueueMessage_)(const PM_DIAGNOSTIC_MESSAGE*) = nu
5151
PM_STATUS(*pFunc_pmDiagnosticFreeMessage_)(PM_DIAGNOSTIC_MESSAGE*) = nullptr;
5252
PM_DIAGNOSTIC_WAKE_REASON(*pFunc_pmDiagnosticWaitForMessage_)(uint32_t) = nullptr;
5353
PM_STATUS(*pFunc_pmDiagnosticUnblockWaitingThread_)() = nullptr;
54-
PM_STATUS(*pFunc_pmSetupFileLogging_)(const char*, PM_DIAGNOSTIC_LEVEL,
55-
PM_DIAGNOSTIC_LEVEL, bool) = nullptr;
5654
// pointers to runtime-resolved internal functions
5755
_CrtMemState(*pFunc_pmCreateHeapCheckpoint__)() = nullptr;
5856
LoggingSingletons(*pFunc_pmLinkLogging__)(std::shared_ptr<pmon::util::log::IChannel>,
5957
std::function<pmon::util::log::IdentificationTable&()>) = nullptr;
6058
void(*pFunc_pmFlushEntryPoint__)() = nullptr;
6159
void(*pFunc_pmSetupODSLogging__)(PM_DIAGNOSTIC_LEVEL, PM_DIAGNOSTIC_LEVEL, bool) = nullptr;
60+
PM_STATUS(*pFunc_pmSetupFileLogging__)(const char*, PM_DIAGNOSTIC_LEVEL,
61+
PM_DIAGNOSTIC_LEVEL, bool) = nullptr;
6262

6363

6464
// internal loader state globals
@@ -169,12 +169,12 @@ PRESENTMON_API2_EXPORT PM_STATUS LoadLibrary_()
169169
RESOLVE(pmDiagnosticFreeMessage);
170170
RESOLVE(pmDiagnosticWaitForMessage);
171171
RESOLVE(pmDiagnosticUnblockWaitingThread);
172-
RESOLVE(pmSetupFileLogging);
173172
// internal
174173
RESOLVE_CPP(pmCreateHeapCheckpoint_);
175174
RESOLVE_CPP(pmLinkLogging_);
176175
RESOLVE_CPP(pmFlushEntryPoint_);
177176
RESOLVE_CPP(pmSetupODSLogging_);
177+
RESOLVE_CPP(pmSetupFileLogging_);
178178
// if we make it here then we have succeeded
179179
middlewareLoadResult_ = PM_STATUS_SUCCESS;
180180
}
@@ -376,11 +376,12 @@ PRESENTMON_API2_EXPORT PM_STATUS pmDiagnosticUnblockWaitingThread()
376376
LoadEndpointsIfEmpty_();
377377
return pFunc_pmDiagnosticUnblockWaitingThread_();
378378
}
379-
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging(const char* path, PM_DIAGNOSTIC_LEVEL logLevel,
379+
380+
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging_(const char* file, PM_DIAGNOSTIC_LEVEL logLevel,
380381
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace)
381382
{
382383
LoadEndpointsIfEmpty_();
383-
return pFunc_pmSetupFileLogging_(path, logLevel, stackTraceLevel, exceptionTrace);
384+
return pFunc_pmSetupFileLogging__(file, logLevel, stackTraceLevel, exceptionTrace);
384385
}
385386

386387

0 commit comments

Comments
 (0)