| 38 | namespace |
| 39 | { |
| 40 | std::shared_ptr<IChannel> MakeChannel() |
| 41 | { |
| 42 | GlobalPolicy::Get().SetSubsystem(Subsystem::IntelPresentmon); |
| 43 | bool synchronousMode = false; |
| 44 | bool enableDiagnostics = false; |
| 45 | try { |
| 46 | synchronousMode = *::p2c::cli::Options::Get().logSynchronous; |
| 47 | enableDiagnostics = *::p2c::cli::Options::Get().enableDiagnostic; |
| 48 | } |
| 49 | catch (...) {} |
| 50 | // channel (use custom deleter to ensure deletion in this module's heap) |
| 51 | auto pChannel = std::shared_ptr<IChannel>{ new Channel{ synchronousMode }, [](Channel* p) { delete p; } }; |
| 52 | // error resolver |
| 53 | auto pErrorResolver = std::make_shared<ErrorCodeResolver>(); |
| 54 | pErrorResolver->AddProvider(std::make_unique<win::HrErrorCodeProvider>()); |
| 55 | pErrorResolver->AddProvider(std::make_unique<pmapi::PmErrorCodeProvider>()); |
| 56 | // error resolving policy |
| 57 | auto pErrPolicy = std::make_shared<ErrorCodeResolvePolicy>(); |
| 58 | pErrPolicy->SetResolver(std::move(pErrorResolver)); |
| 59 | pChannel->AttachComponent(std::move(pErrPolicy)); |
| 60 | // make and add the line-tracking policy |
| 61 | pChannel->AttachComponent(std::make_shared<LinePolicy>()); |
| 62 | // make the formatter |
| 63 | const auto pFormatter = std::make_shared<TextFormatter>(); |
| 64 | // attach drivers |
| 65 | // TODO: test if cwd is writeable, if not write to some other location (temp?) |
| 66 | if (!enableDiagnostics) { |
| 67 | pChannel->AttachComponent(std::make_shared<MsvcDebugDriver>(pFormatter), "drv:dbg"); |
| 68 | } |
| 69 | const auto pFileStrategy = std::make_shared<SimpleFileStrategy>("pm-early-log.txt"); |
| 70 | pChannel->AttachComponent(std::make_shared<BasicFileDriver>(pFormatter, pFileStrategy), "drv:file"); |
| 71 | |
| 72 | return pChannel; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // this is injected into to util::log namespace and hooks into that system |
nothing calls this directly
no test coverage detected