10 #include <spdlog/spdlog.h>
11 #include <spdlog/async.h>
12 #include <spdlog/sinks/stdout_color_sinks.h>
13 #include <spdlog/sinks/basic_file_sink.h>
18 using namespace flexiv;
21 constexpr
char kDefaultLogPattern[] =
"[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v";
28 std::cout <<
"Required arguments: [robot_sn]" << std::endl;
29 std::cout <<
" robot_sn: Serial number of the robot to connect. Remove any space, e.g. Rizon4s-123456" << std::endl;
30 std::cout <<
"Optional arguments: None" << std::endl;
31 std::cout << std::endl;
35 int main(
int argc,
char* argv[])
40 if (argc < 2 || rdk::utility::ProgramArgsExistAny(argc, argv, {
"-h",
"--help"})) {
45 std::string robot_sn = argv[1];
49 ">>> Tutorial description <<<\nThis tutorial shows how to change the logging behaviors of "
56 spdlog::set_level(spdlog::level::warn);
62 }
catch (
const std::exception& e) {
63 spdlog::error(e.what());
69 auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
70 auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(
"example.log",
true);
71 std::vector<spdlog::sink_ptr> sinks {console_sink, file_sink};
73 spdlog::init_thread_pool(10240, 1);
74 auto tp = spdlog::thread_pool();
76 = std::make_shared<spdlog::async_logger>(
"global_logger", sinks.begin(), sinks.end(), tp);
78 logger->set_pattern(kDefaultLogPattern);
81 spdlog::set_default_logger(logger);
84 spdlog::set_level(spdlog::level::info);
89 }
catch (
const std::exception& e) {
90 spdlog::error(e.what());
93 spdlog::warn(
"This message should also appear in the log file");
94 spdlog::info(
"Program finished");
Main interface with the robot, containing several function categories and background services.