Skip to content

Commit eb37ecc

Browse files
committed
improve the logging
1 parent 837cbe8 commit eb37ecc

File tree

11 files changed

+66
-56
lines changed

11 files changed

+66
-56
lines changed

IntelPresentMon/ControlLib/NvidiaPowerTelemetryAdapter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ namespace pwr::nv
188188
// TODO: consider logging failure (lower logging level perhaps)
189189
}
190190
}
191-
192191
}
193192

194-
195193
// insert telemetry into history
196194
std::lock_guard lock{ historyMutex };
197195
history.Push(info);

IntelPresentMon/Core/source/infra/LogSetup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ namespace p2c
119119
infra::util::FolderResolver::Folder::App, L"logs\\");
120120
}
121121
// always enable the logfile for client
122-
const auto logfileNameClient = bool(opt.cefType) ? std::format(L"log-{}-{}.txt",
123-
str::ToWide(*opt.cefType), GetCurrentProcessId()) : L"log.txt"s;
122+
const auto logfileNameClient = bool(opt.cefType) ? std::format(L"pmlog-{}-{}.txt",
123+
str::ToWide(*opt.cefType), GetCurrentProcessId()) : L"pmlog.txt"s;
124124
const auto logfilePathClient = std::filesystem::path{ logFolder } / logfileNameClient;
125125
pChan->AttachComponent(std::make_shared<BasicFileDriver>(std::make_shared<TextFormatter>(),
126126
std::make_shared<SimpleFileStrategy>(logfilePathClient)), "drv:file");
@@ -165,7 +165,7 @@ namespace p2c
165165
}
166166
}
167167
// enable logfile for middleware if we're not doing the copy connection
168-
if (!opt.logMiddlewareCopy) {
168+
if (!opt.logMiddlewareCopy && *opt.cefType == "renderer") {
169169
if (auto sta = pmSetupFileLogging(logFolder.string().c_str(),
170170
(PM_DIAGNOSTIC_LEVEL)pol.GetLogLevel(),
171171
(PM_DIAGNOSTIC_LEVEL)pol.GetTraceLevel(),

IntelPresentMon/PresentMonAPI2/Internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "PresentMonAPI.h"
3+
#include "PresentMonDiagnostics.h"
34
#include "../CommonUtilities/log/Log.h"
45
#include "../CommonUtilities/log/LineTable.h"
56
#include "../CommonUtilities/log/GlobalPolicy.h"
@@ -38,4 +39,5 @@ PRESENTMON_API2_EXPORT LoggingSingletons pmLinkLogging_(
3839
// function to flush the dll's log channel worker queue when before exiting
3940
PRESENTMON_API2_EXPORT void pmFlushEntryPoint_() noexcept;
4041
// set middleware to log using OutputDebugString
41-
PRESENTMON_API2_EXPORT void pmSetupODSLogging_();
42+
PRESENTMON_API2_EXPORT void pmSetupODSLogging_(PM_DIAGNOSTIC_LEVEL logLevel,
43+
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace);

IntelPresentMon/PresentMonAPI2/PresentMonAPI.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
#include "../Interprocess/source/PmStatusError.h"
66
#include "Internal.h"
77
#include "PresentMonAPI.h"
8+
#include "PresentMonDiagnostics.h"
89
#include "../PresentMonMiddleware/LogSetup.h"
910
#include "../Versioning/PresentMonAPIVersion.h"
1011

1112

13+
1214
using namespace pmon;
1315
using namespace pmon::mid;
1416

@@ -77,6 +79,7 @@ PRESENTMON_API2_EXPORT PM_STATUS pmOpenSession_(PM_SESSION_HANDLE* pHandle, cons
7779
pMiddleware = std::make_shared<ConcreteMiddleware>(std::move(pipeName), std::move(introNsm));
7880
*pHandle = pMiddleware.get();
7981
handleMap_[*pHandle] = std::move(pMiddleware);
82+
pmlog_info("Middleware successfully opened session with service");
8083
return PM_STATUS_SUCCESS;
8184
}
8285
catch (...) {
@@ -136,9 +139,11 @@ PRESENTMON_API2_EXPORT void pmFlushEntryPoint_() noexcept
136139
pmon::util::log::FlushEntryPoint();
137140
}
138141

139-
PRESENTMON_API2_EXPORT void pmSetupODSLogging_()
142+
PRESENTMON_API2_EXPORT void pmSetupODSLogging_(PM_DIAGNOSTIC_LEVEL logLevel,
143+
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace)
140144
{
141-
pmon::util::log::SetupODSChannel();
145+
pmon::util::log::SetupODSChannel((pmon::util::log::Level)logLevel,
146+
(pmon::util::log::Level)stackTraceLevel, exceptionTrace);
142147
}
143148

144149
// public endpoints

IntelPresentMon/PresentMonAPI2/PresentMonDiagnostics.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "PresentMonDiagnostics.h"
2+
#include "../CommonUtilities/win/WinAPI.h"
23
#include "../CommonUtilities/log/DiagnosticDriver.h"
34
#include "../CommonUtilities/log/Log.h"
45
#include "../CommonUtilities/Exception.h"
@@ -129,11 +130,12 @@ PRESENTMON_API2_EXPORT PM_STATUS pmDiagnosticUnblockWaitingThread()
129130
PRESENTMON_API2_EXPORT PM_STATUS pmSetupFileLogging(const char* path, PM_DIAGNOSTIC_LEVEL logLevel,
130131
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace)
131132
{
132-
auto fsPath = std::filesystem::path(path);
133+
const auto fsPath = std::filesystem::path(path);
133134
if (!std::filesystem::is_directory(fsPath)) {
134135
return PM_STATUS_NONEXISTENT_FILE_PATH;
135136
}
136-
log::SetupFileChannel(std::move(fsPath), GetLogLevel_(logLevel),
137+
auto file = fsPath / std::format("pmlog-mid-{}.txt", GetCurrentProcessId());
138+
log::SetupFileChannel(std::move(file), GetLogLevel_(logLevel),
137139
GetLogLevel_(stackTraceLevel), exceptionTrace);
138140
return PM_STATUS_SUCCESS;
139141
}

IntelPresentMon/PresentMonAPI2Loader/Implementation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _CrtMemState(*pFunc_pmCreateHeapCheckpoint__)() = nullptr;
5858
LoggingSingletons(*pFunc_pmLinkLogging__)(std::shared_ptr<pmon::util::log::IChannel>,
5959
std::function<pmon::util::log::IdentificationTable&()>) = nullptr;
6060
void(*pFunc_pmFlushEntryPoint__)() = nullptr;
61-
void(*pFunc_pmSetupODSLogging__)() = nullptr;
61+
void(*pFunc_pmSetupODSLogging__)(PM_DIAGNOSTIC_LEVEL, PM_DIAGNOSTIC_LEVEL, bool) = nullptr;
6262

6363

6464
// internal loader state globals
@@ -312,14 +312,15 @@ PRESENTMON_API2_EXPORT void pmFlushEntryPoint_() noexcept
312312
pFunc_pmFlushEntryPoint__();
313313
}
314314
}
315-
PRESENTMON_API2_EXPORT void pmSetupODSLogging_()
315+
PRESENTMON_API2_EXPORT void pmSetupODSLogging_(PM_DIAGNOSTIC_LEVEL logLevel,
316+
PM_DIAGNOSTIC_LEVEL stackTraceLevel, bool exceptionTrace)
316317
{
317318
if (!middlewareLoadedSuccessfully_) {
318319
if (auto status = LoadLibrary_(); status != PM_STATUS_SUCCESS) {
319320
throw LoaderExcept_(status);
320321
}
321322
}
322-
pFunc_pmSetupODSLogging__();
323+
pFunc_pmSetupODSLogging__(logLevel, stackTraceLevel, exceptionTrace);
323324
}
324325
PRESENTMON_API2_EXPORT PM_STATUS pmDiagnosticSetup(const PM_DIAGNOSTIC_CONFIGURATION* pConfig)
325326
{

0 commit comments

Comments
 (0)