diff --git a/src/main.cpp b/src/main.cpp index 89f9540..088f9d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,6 +81,7 @@ struct NanoSm { int Run() { ev.Post([this]() { this->SpawnAllApps(); + nanosm::log::Info("NanoSm", "NanoSm initialized and running successfully."); }); try { @@ -120,16 +121,14 @@ int main(int argc, char** argv) { auto tomlTable = toml::parse_file(configPath.string()); if(tomlTable["nanosm"].is_table() && tomlTable["nanosm"]["apps"].is_table()) { - auto restartptr = tomlTable["nanosm"]["restart-time"].as_integer(); - - if(!restartptr) { + if(auto restartTimePtr = tomlTable["nanosm"]["restart-time"].as_integer(); !restartTimePtr) { nanosm::log::Warn("NanoSm", "No restart time provided in nanosm.toml. Defaulting to 1 second."); nanosm.SetRestartTime(1); } else { - nanosm.SetRestartTime(static_cast(restartptr->get())); + nanosm.SetRestartTime(static_cast(restartTimePtr->get())); } - for(auto [key, value] : *tomlTable["nanosm"]["apps"].as_table()) { + for(auto& [key, value] : *tomlTable["nanosm"]["apps"].as_table()) { if(!value.is_table()) { nanosm::log::Warn("NanoSm", "Ignoring invalid app \"{}\" in configuration file", key.str()); continue; @@ -149,7 +148,7 @@ int main(int argc, char** argv) { nanosm.AddApp(std::string(key.data(), key.length()), std::string(cmd.data(), cmd.length())); } } else { - nanosm::log::Error("NanoSm", "Configuration file {} doesn't have required values. Exiting with failure.", configPath.string()); + nanosm::log::Error("NanoSm", "Configuration file {} doesn't have required tables. Exiting with failure.", configPath.string()); return 1; }