mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 07:00:10 +01:00
things
This commit is contained in:
parent
eb27ac56e3
commit
fe829f2913
3 changed files with 28 additions and 3 deletions
|
|
@ -99,7 +99,8 @@ std::vector<SArgumentKey>::iterator CArgumentParserImpl::getValue(const std::str
|
|||
return it;
|
||||
}
|
||||
|
||||
std::expected<void, std::string> CArgumentParserImpl::registerOption(const std::string_view& name, const std::string_view& abbrev, const std::string_view& description, eArgumentType type) {
|
||||
std::expected<void, std::string> CArgumentParserImpl::registerOption(const std::string_view& name, const std::string_view& abbrev, const std::string_view& description,
|
||||
eArgumentType type) {
|
||||
if (getValue(name) != m_values.end() || getValue(abbrev) != m_values.end())
|
||||
return std::unexpected("Value already exists");
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ void CLogger::setTime(bool enabled) {
|
|||
}
|
||||
|
||||
void CLogger::setEnableStdout(bool enabled) {
|
||||
m_impl->m_stdoutEnabled;
|
||||
m_impl->m_stdoutEnabled = enabled;
|
||||
m_impl->updateParentShouldLog();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ TEST(CLI, Logger) {
|
|||
|
||||
EXPECT_EQ(logger.rollingLog(), "DEBUG ]: Hello!\nTRACE ]: Hello, Trace!");
|
||||
|
||||
logger.setEnableStdout(false);
|
||||
|
||||
logger.log(Hyprutils::CLI::LOG_ERR, "Error");
|
||||
|
||||
EXPECT_EQ(logger.rollingLog(), "DEBUG ]: Hello!\nTRACE ]: Hello, Trace!");
|
||||
|
||||
auto res = logger.setOutputFile("./loggerFile.log");
|
||||
EXPECT_TRUE(res);
|
||||
|
||||
|
|
@ -39,4 +45,22 @@ TEST(CLI, Logger) {
|
|||
|
||||
std::error_code ec;
|
||||
std::filesystem::remove("./loggerFile.log", ec);
|
||||
|
||||
// TODO: maybe find a way to test the times and color?
|
||||
logger.setEnableStdout(true);
|
||||
logger.setTime(true);
|
||||
|
||||
logger.log(Hyprutils::CLI::LOG_WARN, "Timed warning!");
|
||||
|
||||
logger.setEnableColor(false);
|
||||
|
||||
logger.log(Hyprutils::CLI::LOG_CRIT, "rip");
|
||||
|
||||
// spam some logs to check rolling
|
||||
for (size_t i = 0; i < 1000; ++i) {
|
||||
logger.log(LOG_DEBUG, "Log log log!");
|
||||
}
|
||||
|
||||
EXPECT_TRUE(logger.rollingLog().size() < 4096);
|
||||
EXPECT_TRUE(logger.rollingLog().starts_with("DEBUG")); // test the breaking is done correctly
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue