Skip to content

Commit e59e77c

Browse files
committed
Changed logging to match documentation
1 parent 1a9f73f commit e59e77c

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/mtconnect/configuration/agent_config.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ namespace mtconnect::configuration {
529529

530530
ConfigOptions options;
531531
AddDefaultedOptions(logger, options,
532-
{{"max_size", "10mb"s},
533-
{"rotation_size", "2mb"s},
532+
{{"max_size", "2mb"s},
533+
{"max_archive_size", "10mb"s},
534534
{"max_index", 9},
535535
{"file_name", defaultFileName},
536536
{"archive_pattern", defaultArchivePattern}});
@@ -594,16 +594,16 @@ namespace mtconnect::configuration {
594594
}
595595
}
596596

597-
auto &maxLogFileSize = logChannel.m_maxLogFileSize;
597+
auto &maxLogArchiveSize = logChannel.m_maxLogArchiveSize;
598598
auto &logRotationSize = logChannel.m_logRotationSize;
599599
auto &rotationLogInterval = logChannel.m_rotationLogInterval;
600600
auto &logArchivePattern = logChannel.m_logArchivePattern;
601601
auto &logDirectory = logChannel.m_logDirectory;
602602
auto &archiveLogDirectory = logChannel.m_archiveLogDirectory;
603603
auto &logFileName = logChannel.m_logFileName;
604604

605-
maxLogFileSize = ConvertFileSize(options, "max_size", maxLogFileSize);
606-
logRotationSize = ConvertFileSize(options, "rotation_size", logRotationSize);
605+
maxLogArchiveSize = ConvertFileSize(options, "max_archive_size", maxLogArchiveSize);
606+
logRotationSize = ConvertFileSize(options, "max_size", logRotationSize);
607607
int max_index = *GetOption<int>(options, "max_index");
608608

609609
if (auto sched = GetOption<string>(options, "schedule"))
@@ -673,7 +673,7 @@ namespace mtconnect::configuration {
673673

674674
// Set up where the rotated files will be stored
675675
sink->locked_backend()->set_file_collector(logr::sinks::file::make_collector(
676-
kw::target = archiveLogDirectory.string(), kw::max_size = maxLogFileSize,
676+
kw::target = archiveLogDirectory.string(), kw::max_size = maxLogArchiveSize,
677677
kw::max_files = max_index));
678678

679679
if (rotationLogInterval > 0)

‎src/mtconnect/configuration/agent_config.hpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ namespace mtconnect {
193193

194194
/// @brief Get the maximum size of all the log files
195195
/// @return the maximum size of all log files
196-
auto getMaxLogFileSize(const std::string &channelName = "agent")
196+
auto getLogRotationSize(const std::string &channelName = "agent")
197197
{
198-
return m_logChannels[channelName].m_maxLogFileSize;
198+
return m_logChannels[channelName].m_logRotationSize;
199199
}
200200
/// @brief the maximum size of a log file when it triggers rolling over
201201
/// @return the maxumum site of a log file
202-
auto getLogRotationSize(const std::string &channelName = "agent")
202+
auto getMaxLogArchiveSize(const std::string &channelName = "agent")
203203
{
204-
return m_logChannels[channelName].m_logRotationSize;
204+
return m_logChannels[channelName].m_maxLogArchiveSize;
205205
}
206206
/// @brief How often to roll over the log file
207207
///
@@ -364,7 +364,7 @@ namespace mtconnect {
364364
std::filesystem::path m_logArchivePattern;
365365
std::filesystem::path m_logFileName;
366366

367-
int64_t m_maxLogFileSize {0};
367+
int64_t m_maxLogArchiveSize {0};
368368
int64_t m_logRotationSize {0};
369369
int64_t m_rotationLogInterval {0};
370370

‎test_package/config_test.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ logger_config {
918918
R"(
919919
logger_config {
920920
max_size = 1gb
921-
rotation_size = 20gb
921+
max_archive_size = 20gb
922922
}
923923
)";
924924

@@ -928,8 +928,8 @@ logger_config {
928928
ASSERT_TRUE(sink);
929929

930930
EXPECT_EQ(severity_level::info, m_config->getLogLevel());
931-
EXPECT_EQ(1ll * 1024 * 1024 * 1024, m_config->getMaxLogFileSize());
932-
EXPECT_EQ(20ll * 1024 * 1024 * 1024, m_config->getLogRotationSize());
931+
EXPECT_EQ(1ll * 1024 * 1024 * 1024, m_config->getLogRotationSize());
932+
EXPECT_EQ(20ll * 1024 * 1024 * 1024, m_config->getMaxLogArchiveSize());
933933
}
934934

935935
TEST_F(ConfigTest, log_should_configure_logging_level)
@@ -1011,7 +1011,7 @@ logger_config {
10111011
file_name = ./logging.log
10121012
archive_pattern = logs/logging_%N.log
10131013
# Make if very small
1014-
rotation_size = 1k
1014+
max_size = 1k
10151015
}
10161016
)";
10171017

0 commit comments

Comments
 (0)