Skip to content

Commit 99770f8

Browse files
authored
Suppress unnecessary error log for ERROR_NOT_SUPPORTED cases (#215)
* Suppress unnecessary error log for ERROR_NOT_SUPPORTED cases
1 parent 3234439 commit 99770f8

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

LogMonitor/src/LogMonitor/LogFileMonitor.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,21 @@ LogFileMonitor::InitializeDirectoryChangeEventsQueue()
701701
nullptr);
702702
if (logFile == INVALID_HANDLE_VALUE)
703703
{
704-
logWriter.TraceError(
705-
Utility::FormatString(
706-
L"Error in log file monitor. Failed to open file %ws. Error = %d",
707-
fileName.c_str(),
708-
GetLastError()
709-
).c_str()
710-
);
704+
//
705+
// Added a conditional check to suppress logging for ERROR_NOT_SUPPORTED (benign error).
706+
// This prevents unnecessary log pollution while still logging other actionable errors.
707+
// https://github.com/microsoft/windows-container-tools/issues/125#issuecomment-3056545183
708+
//
709+
if (GetLastError() != ERROR_NOT_SUPPORTED)
710+
{
711+
logWriter.TraceError(
712+
Utility::FormatString(
713+
L"Error in log file monitor. Failed to open file %ws. Error = %d",
714+
fileName.c_str(),
715+
GetLastError()
716+
).c_str()
717+
);
718+
}
711719

712720
//
713721
// Ignore failure and continue. In the worst case we will
@@ -1079,13 +1087,19 @@ LogFileMonitor::LogFileAddEventHandler(
10791087
if (status != ERROR_SUCCESS)
10801088
{
10811089
status = GetLastError();
1082-
logWriter.TraceError(
1083-
Utility::FormatString(
1084-
L"Error in log file monitor. Failed to query file ID. File: %ws. Error: %d",
1085-
fullLongPath.c_str(),
1086-
status
1087-
).c_str()
1088-
);
1090+
// Added a conditional check to suppress logging for ERROR_NOT_SUPPORTED (benign error).
1091+
// This prevents unnecessary log pollution while still logging other actionable errors.
1092+
// https://github.com/microsoft/windows-container-tools/issues/125#issuecomment-3056545183
1093+
if (status != ERROR_NOT_SUPPORTED)
1094+
{
1095+
logWriter.TraceError(
1096+
Utility::FormatString(
1097+
L"Error in log file monitor. Failed to query file ID for File: %ws. Error: %d",
1098+
fullLongPath.c_str(),
1099+
status
1100+
).c_str()
1101+
);
1102+
}
10891103
}
10901104

10911105
status = ReadLogFile(logFileInfo);

0 commit comments

Comments
 (0)