Skip to content

Commit f46a954

Browse files
authored
Address review: move format syntax to enum comment, remove redundant FileLogger comment, move SettingLoggingFormat test, remove fff from spellcheck
1 parent 046bef9 commit f46a954

4 files changed

Lines changed: 59 additions & 61 deletions

File tree

.github/actions/spelling/expect.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ fdw
179179
fdwgp
180180
FECAFEB
181181
fedorapeople
182-
fff
183182
fileinuse
184183
filemode
185184
Filetime

src/AppInstallerCLITests/UserSettings.cpp

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,64 @@ TEST_CASE("SettingLoggingFileNameStrategy", "[settings]") {
386386
}
387387
}
388388

389+
TEST_CASE("SettingLoggingFormat", "[settings]")
390+
{
391+
auto again = DeleteUserSettingsFiles();
392+
393+
SECTION("Default value")
394+
{
395+
UserSettingsTest userSettingTest;
396+
397+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
398+
REQUIRE(userSettingTest.GetWarnings().size() == 0);
399+
}
400+
SECTION("WinGet")
401+
{
402+
std::string_view json = R"({ "logging": { "format": "winget" } })";
403+
SetSetting(Stream::PrimaryUserSettings, json);
404+
UserSettingsTest userSettingTest;
405+
406+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
407+
REQUIRE(userSettingTest.GetWarnings().size() == 0);
408+
}
409+
SECTION("CCM")
410+
{
411+
std::string_view json = R"({ "logging": { "format": "ccm" } })";
412+
SetSetting(Stream::PrimaryUserSettings, json);
413+
UserSettingsTest userSettingTest;
414+
415+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::CCM);
416+
REQUIRE(userSettingTest.GetWarnings().size() == 0);
417+
}
418+
SECTION("Case insensitive CCM")
419+
{
420+
std::string_view json = R"({ "logging": { "format": "CCM" } })";
421+
SetSetting(Stream::PrimaryUserSettings, json);
422+
UserSettingsTest userSettingTest;
423+
424+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::CCM);
425+
REQUIRE(userSettingTest.GetWarnings().size() == 0);
426+
}
427+
SECTION("Bad value")
428+
{
429+
std::string_view json = R"({ "logging": { "format": "cmtrace" } })";
430+
SetSetting(Stream::PrimaryUserSettings, json);
431+
UserSettingsTest userSettingTest;
432+
433+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
434+
REQUIRE(userSettingTest.GetWarnings().size() == 1);
435+
}
436+
SECTION("Bad value type")
437+
{
438+
std::string_view json = R"({ "logging": { "format": true } })";
439+
SetSetting(Stream::PrimaryUserSettings, json);
440+
UserSettingsTest userSettingTest;
441+
442+
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
443+
REQUIRE(userSettingTest.GetWarnings().size() == 1);
444+
}
445+
}
446+
389447
TEST_CASE("SettingAutoUpdateIntervalInMinutes", "[settings]")
390448
{
391449
auto again = DeleteUserSettingsFiles();
@@ -925,64 +983,6 @@ TEST_CASE("SettingOutputSortDirection", "[settings]")
925983
}
926984
}
927985

928-
TEST_CASE("SettingLoggingFormat", "[settings]")
929-
{
930-
auto again = DeleteUserSettingsFiles();
931-
932-
SECTION("Default value")
933-
{
934-
UserSettingsTest userSettingTest;
935-
936-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
937-
REQUIRE(userSettingTest.GetWarnings().size() == 0);
938-
}
939-
SECTION("WinGet")
940-
{
941-
std::string_view json = R"({ "logging": { "format": "winget" } })";
942-
SetSetting(Stream::PrimaryUserSettings, json);
943-
UserSettingsTest userSettingTest;
944-
945-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
946-
REQUIRE(userSettingTest.GetWarnings().size() == 0);
947-
}
948-
SECTION("CCM")
949-
{
950-
std::string_view json = R"({ "logging": { "format": "ccm" } })";
951-
SetSetting(Stream::PrimaryUserSettings, json);
952-
UserSettingsTest userSettingTest;
953-
954-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::CCM);
955-
REQUIRE(userSettingTest.GetWarnings().size() == 0);
956-
}
957-
SECTION("Case insensitive CCM")
958-
{
959-
std::string_view json = R"({ "logging": { "format": "CCM" } })";
960-
SetSetting(Stream::PrimaryUserSettings, json);
961-
UserSettingsTest userSettingTest;
962-
963-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::CCM);
964-
REQUIRE(userSettingTest.GetWarnings().size() == 0);
965-
}
966-
SECTION("Bad value")
967-
{
968-
std::string_view json = R"({ "logging": { "format": "cmtrace" } })";
969-
SetSetting(Stream::PrimaryUserSettings, json);
970-
UserSettingsTest userSettingTest;
971-
972-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
973-
REQUIRE(userSettingTest.GetWarnings().size() == 1);
974-
}
975-
SECTION("Bad value type")
976-
{
977-
std::string_view json = R"({ "logging": { "format": true } })";
978-
SetSetting(Stream::PrimaryUserSettings, json);
979-
UserSettingsTest userSettingTest;
980-
981-
REQUIRE(userSettingTest.Get<Setting::LoggingFormat>() == LogFileFormat::WinGet);
982-
REQUIRE(userSettingTest.GetWarnings().size() == 1);
983-
}
984-
}
985-
986986
TEST_CASE("ConvertToSortField", "[settings]")
987987
{
988988
SECTION("Valid values - lowercase")

src/AppInstallerCommonCore/FileLogger.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace AppInstaller::Logging
3030
}
3131

3232
// Formats a log line in CCM (CMTrace-compatible) format.
33-
// CCM log format: <![LOG[message]LOG]!><time="HH:mm:ss.fff+###" date="MM-dd-YYYY" component="channel" context="" type="N" thread="TID" file="">
3433
std::string ToCCMLogLine(Channel channel, Level level, std::string_view message)
3534
{
3635
auto now = std::chrono::system_clock::now();

src/AppInstallerSharedLib/Public/AppInstallerLogging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace AppInstaller::Logging
103103
{
104104
// Default WinGet format: "<timestamp> <level> [channel] message"
105105
WinGet,
106-
// CCM/CMTrace-compatible format recognized by CMTrace and Microsoft Endpoint Configuration Manager log viewers
106+
// CCM/CMTrace-compatible format: <![LOG[message]LOG]!><time="HH:mm:ss.fff+###" date="MM-dd-YYYY" component="channel" context="" type="N" thread="TID" file="">
107107
CCM,
108108
};
109109

0 commit comments

Comments
 (0)