10#include "utility/example_shared.h"
18#include <mi/base/handle.h>
19#include <mi/base/ilogger.h>
21#include <nv/index/iindex.h>
22#include <nv/index/iindex_debug_configuration.h>
24#include <nv/index/app/string_dict.h>
25#include <nv/index/app/index_connect.h>
51 fprintf(stdout,
"info: My_receiving_logger is destructed.\n");
57 mi::base::Message_severity level,
58 const char* module_category,
59 const mi::base::Message_details&,
62 const char *log_level = get_log_level( level);
63 fprintf(stdout,
"info: Log level = '%s', module:category = '%s', message = '%s'\n",
64 log_level, module_category,
message);
73 const char* get_log_level(mi::base::Message_severity level)
77 case mi::base:
:MESSAGE_SEVERITY_FATAL:
78 return "My_receiving_logger: FATAL";
79 case mi::base:
:MESSAGE_SEVERITY_ERROR:
80 return "My_receiving_logger: ERROR";
81 case mi::base:
:MESSAGE_SEVERITY_WARNING:
82 return "My_receiving_logger: WARNING";
83 case mi::base:
:MESSAGE_SEVERITY_INFO:
84 return "My_receiving_logger: INFO";
85 case mi::base:
:MESSAGE_SEVERITY_VERBOSE:
86 return "My_receiving_logger: VERBOSE";
87 case mi::base:
:MESSAGE_SEVERITY_DEBUG:
88 return "My_receiving_logger: DEBUG";
98 public nv::index::app::Index_connect
104 m_is_unittest_mode(false)
119 bool m_is_unittest_mode;
124 const std::string com_name = options.get(
"command:",
"<unknown_command>");
125 m_is_unittest_mode = nv::index::app::get_bool(options.get(
"unittest",
"false"));
128 if(options.is_defined(
"h"))
130 std::cout <<
"info: Usage: " << com_name <<
" [option]\n"
132 <<
" printout this message\n"
133 <<
" [-unittest {0|1}\n"
134 <<
" when true, unit test mode.\n"
135 <<
" [-dice::verbose severity_level]\n"
136 <<
" verbose severity level (3 is info.). (default: "
137 << options.get(
"dice::verbose")
147 mi::neuraylib::ILogging_configuration* logging_configuration,
148 nv::index::app::String_dict& option) CPP11_OVERRIDE
150 assert(logging_configuration != 0);
153 nv::index::app::Forwarding_logger::set_index_instance(get_index_interface());
154 set_forwarding_logger_installed(
true);
156 mi::base::Handle<mi::base::ILogger> nvindex_forwarding_logger(
157 get_index_interface()->get_forwarding_logger());
162 info_cout(
"current log level = " + nv::index::app::to_string(logging_configuration->get_log_level()), option);
163 logging_configuration->set_log_level(mi::base:
:MESSAGE_SEVERITY_ERROR);
164 info_cout(
"set log level to " + nv::index::app::to_string(logging_configuration->get_log_level()), option);
165 nvindex_forwarding_logger->message(mi::base:
:MESSAGE_SEVERITY_INFO,
166 "APP:MAIN",
"This info is filered out.\n");
167 logging_configuration->set_log_level(mi::base:
:MESSAGE_SEVERITY_INFO);
169 if(m_is_unittest_mode)
172 logging_configuration->set_log_level(mi::base:
:MESSAGE_SEVERITY_WARNING);
176 info_cout(
"set log level to " + nv::index::app::to_string(logging_configuration->get_log_level()), option);
177 nvindex_forwarding_logger->message(mi::base:
:MESSAGE_SEVERITY_INFO,
178 "APP:MAIN",
"This should be seen.\n");
183 logging_configuration->set_receiving_logger(logger.get());
189 mi::neuraylib::INetwork_configuration* network_configuration,
190 nv::index::app::String_dict& options) CPP11_OVERRIDE
195 const bool is_unittest = nv::index::app::get_bool(options.get(
"unittest"));
198 info_cout(
"NETWORK: disabled networking mode.", options);
199 network_configuration->set_mode(mi::neuraylib::INetwork_configuration:
:MODE_OFF);
203 return initialize_networking_as_default_udp(network_configuration, options);
207 nv::index::IIndex_debug_configuration* index_debug_configuration,
208 nv::index::app::String_dict& options)
211 index_debug_configuration->set_option(
"disable_sse=1");
212 info_cout(
"IIndex_debug_configuration: disabled sse.", options);
221 nv::index::app::String_dict option = get_options();
222 info_cout(std::string(
"NVIDIA IndeX version: ") + get_index_interface()->get_version(), option);
225 mi::base::Handle<mi::neuraylib::ILogging_configuration> logging_configuration(
226 get_index_interface()->get_api_component<mi::neuraylib::ILogging_configuration>());
228 logging_configuration->set_receiving_logger(0);
229 info_cout(
"The receiving logger has been reset.", option);
236int main(
int argc,
const char* argv[])
238 nv::index::app::String_dict sdict;
239 sdict.insert(
"unittest",
"0");
240 sdict.insert(
"dice::verbose",
"3");
244 configuration.initialize(argc, argv, sdict);
248 const mi::Sint32 exit_code = configuration.
launch();
249 INFO_LOG <<
"Shutting down ...";
virtual bool evaluate_options(nv::index::app::String_dict &options) CPP11_OVERRIDE
virtual bool initialize_index_debug_configuration(nv::index::IIndex_debug_configuration *index_debug_configuration, nv::index::app::String_dict &options)
virtual bool initialize_networking(mi::neuraylib::INetwork_configuration *network_configuration, nv::index::app::String_dict &options) CPP11_OVERRIDE
bool initialize_logging(mi::neuraylib::ILogging_configuration *logging_configuration, nv::index::app::String_dict &option) CPP11_OVERRIDE
receiving logger example.
bool m_is_show_destruct_message
My_receiving_logger(bool is_show_destruct_message)
virtual ~My_receiving_logger()
virtual void message(mi::base::Message_severity level, const char *module_category, const mi::base::Message_details &, const char *message)
int main(int argc, const char *argv[])
#define check_success(expr)