Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/mnist-learn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#include <spdlog/spdlog.h>
Comment thread
artiomn marked this conversation as resolved.
Outdated

#include <iostream>

#include "dataset.h"
Expand Down Expand Up @@ -67,6 +69,8 @@ int main(int argc, char** argv)
if (!model_desc_opt.has_value()) return EXIT_FAILURE;
const ModelDescription& model_desc = model_desc_opt.value();

spdlog::set_level(static_cast<spdlog::level::level_enum>(model_desc.spdlog_level_));

std::cout << "Starting model:\n" << model_desc << std::endl;

// Starting model according to selected type.
Expand Down
6 changes: 6 additions & 0 deletions examples/mnist-learn/model_desc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "model_desc.h"

#include <spdlog/spdlog.h>
Comment thread
DavidIkov marked this conversation as resolved.
Outdated

std::ostream& operator<<(std::ostream& stream, ModelDescription const& desc)
{
stream << "Model type: ";
Expand Down Expand Up @@ -55,5 +57,9 @@ std::ostream& operator<<(std::ostream& stream, ModelDescription const& desc)
else
stream << "Model saving path: " << desc.model_saving_path_ << "\n";

stream << "Spdlog logging level: "
<< spdlog::level::to_string_view(static_cast<spdlog::level::level_enum>(desc.spdlog_level_)).begin() << "\n";

Comment thread
artiomn marked this conversation as resolved.
Outdated

return stream;
}
4 changes: 4 additions & 0 deletions examples/mnist-learn/model_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ struct ModelDescription

/// Path to folder for saving trained model in sonata format.
std::filesystem::path model_saving_path_;

/// Spdlog logging level.
// cppcheck-suppress unusedStructMember
int spdlog_level_;
Comment thread
artiomn marked this conversation as resolved.
Outdated
};


Expand Down
22 changes: 21 additions & 1 deletion examples/mnist-learn/parse_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "parse_arguments.h"

#include <spdlog/spdlog.h>

#include <iostream>
#include <string>

Expand All @@ -42,7 +44,8 @@ std::optional<ModelDescription> parse_arguments(int argc, char** argv)
"log_path", po::value<std::string>()->default_value(""),
"path for putting logs. if no path is specified, no logs will be produced.")(
"model_path", po::value<std::string>()->default_value(""),
"path for saving trained model. if no path is specified, model wont be saved.");
"path for saving trained model. if no path is specified, model wont be saved.")(
"spdlog_level", po::value<std::string>()->default_value("info"), "spdlog logging level.");
Comment thread
artiomn marked this conversation as resolved.
Outdated

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand Down Expand Up @@ -154,5 +157,22 @@ std::optional<ModelDescription> parse_arguments(int argc, char** argv)
model_desc.model_saving_path_ = "";
}

if (vm.count("spdlog_level"))
{
model_desc.spdlog_level_ = spdlog::level::from_str(vm["spdlog_level"].as<std::string>());
if (model_desc.spdlog_level_ == spdlog::level::off)
{
std::cout << "Spdlog logging level is incorrect." << std::endl;
std::cout << desc << std::endl;
return std::nullopt;
}
}
else
{
std::cout << "Spdlog logging level not specified." << std::endl;
std::cout << desc << std::endl;
return std::nullopt;
}
Comment thread
artiomn marked this conversation as resolved.
Outdated

return model_desc;
}
3 changes: 0 additions & 3 deletions knp/core-library/impl/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace knp::core
Backend::Backend()
: message_bus_{knp::core::MessageBus::construct_bus()}, message_endpoint_(message_bus_->create_endpoint())
{
#if (!defined(NDEBUG))
spdlog::set_level(spdlog::level::trace);
#endif
}


Expand Down
Loading