| 318 | } |
| 319 | |
| 320 | int main(int argc, char* argv[]) |
| 321 | { |
| 322 | try { |
| 323 | // command line options initialization |
| 324 | if (auto e = clio::Options::Init(argc, argv, true)) { |
| 325 | pmlog_error(clio::Options::GetDiagnostics()).no_trace(); |
| 326 | std::cerr << clio::Options::GetDiagnostics() << std::endl; |
| 327 | return *e; |
| 328 | } |
| 329 | } |
| 330 | catch (...) { |
| 331 | const auto exr = pmon::util::ReportException("Exception caught during SampleClient option initialization"); |
| 332 | std::cout << "Error: " << exr.first << std::endl; |
| 333 | pmlog_error(exr); |
| 334 | return -1; |
| 335 | } |
| 336 | |
| 337 | auto& opt = clio::Options::Get(); |
| 338 | const auto mode = *opt.mode; |
| 339 | |
| 340 | // crash logging mode intentionally runs without top-level exception handling |
| 341 | if (mode == clio::Mode::LoggingCrashTest) { |
| 342 | if (opt.middlewareDllPath) { |
| 343 | pmLoaderSetPathToMiddlewareDll_(opt.middlewareDllPath->c_str()); |
| 344 | } |
| 345 | |
| 346 | p2sam::LogChannelManager zLogMan_; |
| 347 | p2sam::ConfigureLogging(); |
| 348 | |
| 349 | return RunLoggingCrashTest(*opt.submode); |
| 350 | } |
| 351 | |
| 352 | try { |
| 353 | // use the middleware in the dev path esp. if we are running debug build |
| 354 | // important to do this before any intra-process log linking occurs |
| 355 | if (opt.middlewareDllPath) { |
| 356 | pmLoaderSetPathToMiddlewareDll_(opt.middlewareDllPath->c_str()); |
| 357 | } |
| 358 | |
| 359 | // setup logging, including middleware intra-process cross-module link |
| 360 | p2sam::LogChannelManager zLogMan_; |
| 361 | p2sam::ConfigureLogging(); |
| 362 | |
| 363 | // helper for connecting a pmapi session |
| 364 | const auto ConnectSession = [&] { |
| 365 | if (opt.controlPipe) { |
| 366 | return std::make_unique<pmapi::Session>(*opt.controlPipe); |
| 367 | } |
| 368 | return std::make_unique<pmapi::Session>(); |
| 369 | }; |
| 370 | |
| 371 | // determine requested mode to run the sample app in |
| 372 | switch (mode) { |
| 373 | case clio::Mode::LogDemo: |
| 374 | RunLogDemo(*opt.submode); break; |
| 375 | case clio::Mode::DiagnosticsDemo: |
| 376 | RunDiagnosticDemo(*opt.submode); break; |
| 377 | case clio::Mode::Introspection: |
nothing calls this directly
no test coverage detected