Skip to content

Commit

Permalink
Rename Process Monitor Configuration Fields for Consistency (#185)
Browse files Browse the repository at this point in the history
* change tagging

Signed-off-by: Charity Kathure <ckathure@microsoft.com>

---------

Signed-off-by: Charity Kathure <ckathure@microsoft.com>
Co-authored-by: Charity Kathure <ckathure@microsoft.com>
  • Loading branch information
CharityKathure and Charity Kathure authored Aug 23, 2024
1 parent 808b133 commit 1af6920
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LogMonitor/LogMonitorTests/ConfigFileParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ namespace LogMonitorTests
}";

std::wstring logFormat = L"custom";
std::wstring customLogFormat = L"{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Logline':'%Logline%'}";
std::wstring customLogFormat = L"{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Message':'%Message%'}";
{
std::wstring configFileStr = Utility::FormatString(
configFileStrFormat.c_str(),
Expand Down
12 changes: 6 additions & 6 deletions LogMonitor/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Each log source tracked by log monitor <em>(ETW, Log File, Events, and Process M
<strong>Process Monitor:</strong>
- `Source`: The log source (Process Monitor)
- `TimeStamp`: Time at which the process was executed
- `Logline` or `logEntry` : The output of the process/command executed
- `Message` : The output of the process/command executed

### Sample Custom Log Configuration

Expand All @@ -431,18 +431,18 @@ Each log source tracked by log monitor <em>(ETW, Log File, Events, and Process M
"level": "Information"
}
],
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Severity':'%Severity%', 'ProviderId':'%ProviderId%', 'ProviderName':'%ProviderName%', 'EventId':'%EventId%', 'EventData':'%EventData%'}"
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'Source':'%Source%', 'Severity':'%Severity%', 'ProviderId':'%ProviderId%', 'ProviderName':'%ProviderName%', 'EventId':'%EventId%', 'EventData':'%EventData%'}"
},
{
"type": "File",
"directory": "c:\\inetpub\\logs",
"filter": "*.log",
"includeSubdirectories": true,
"customLogFormat": "{'message':%Message%,'source':%Source%,'fileName':%FileName%}"
"customLogFormat": "{'Message':%Message%,'Source':%Source%,'fileName':%FileName%}"
},
{
"type": "Process",
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Logline':'%Logline%'}"
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'Source':'%Source%', 'Message':'%Message%'}"
}
]
}
Expand All @@ -468,11 +468,11 @@ For example:
"level": "Information"
}
],
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Severity':'%Severity%', 'ProviderId':'%ProviderId%', 'ProviderName':'%ProviderName%', 'EventId':'%EventId%', 'EventData':'%EventData%'}|json"
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'Source':'%Source%', 'Severity':'%Severity%', 'ProviderId':'%ProviderId%', 'ProviderName':'%ProviderName%', 'EventId':'%EventId%', 'EventData':'%EventData%'}|json"
},
{
"type": "Process",
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Logline':'%Logline%'}|JSON"
"customLogFormat": "{'TimeStamp':'%TimeStamp%', 'Source':'%Source%', 'Message':'%Message%'}|JSON"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion LogMonitor/src/LogMonitor/Parser/LoggerSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class SourceETW : LogSource
class SourceProcess : LogSource
{
public:
std::wstring CustomLogFormat = L"[%TimeStamp%] [%Source%] [%LogEntry%]";
std::wstring CustomLogFormat = L"[%TimeStamp%] [%Source%] [%Message%]";

static bool Unwrap(
_In_ AttributesMap& Attributes,
Expand Down
5 changes: 2 additions & 3 deletions LogMonitor/src/LogMonitor/ProcessMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ size_t FormatCustomLog(char* chBuf) {
logEntry.currentTime = Utility::SystemTimeToString(st).c_str();

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> fromBytesconverter;
logEntry.logLine = fromBytesconverter.from_bytes(chBufCpy);
logEntry.message = fromBytesconverter.from_bytes(chBufCpy);

std::wstring_convert<std::codecvt_utf8<wchar_t>> toBytesconverter;
std::wstring formattedLog = Utility::FormatEventLineLog(processCustomLogFormat, &logEntry, logEntry.source);
Expand Down Expand Up @@ -432,8 +432,7 @@ std::wstring ProcessMonitor::ProcessFieldsMapping(_In_ std::wstring fileFields,

if (Utility::CompareWStrings(fileFields, L"TimeStamp")) oss << pLogEntry->currentTime;
if (Utility::CompareWStrings(fileFields, L"Source")) oss << pLogEntry->source;
if (Utility::CompareWStrings(fileFields, L"logLine")
|| Utility::CompareWStrings(fileFields, L"logEntry")) oss << pLogEntry->logLine;
if (Utility::CompareWStrings(fileFields, L"Message")) oss << pLogEntry->message;

return oss.str();
}
2 changes: 1 addition & 1 deletion LogMonitor/src/LogMonitor/ProcessMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
struct ProcessLogEntry {
std::wstring source;
std::wstring currentTime;
std::wstring logLine;
std::wstring message;
};

DWORD CreateAndMonitorProcess(std::wstring& Cmdline, std::wstring LogFormat, std::wstring ProcessCustomLogFormat);
Expand Down

0 comments on commit 1af6920

Please sign in to comment.