Malloy
Loading...
Searching...
No Matches
connection_t.hpp
1#pragma once
2
3#include <spdlog/logger.h>
4
5#include <variant>
6#include <memory>
7
8namespace malloy::server::http
9{
10 class connection_plain;
11
12#if MALLOY_FEATURE_TLS
13 class connection_tls;
14#endif
15
19 using connection_t = std::variant<
20 std::shared_ptr<connection_plain>
21#if MALLOY_FEATURE_TLS
22 ,std::shared_ptr<connection_tls>
23#endif
24 >;
25
26}
27
28namespace malloy
29{
30
42 // ToDo: Move fmt in lambda capture?
43 // ToDo: Move args in lambda capture?
44 template<typename ...Args>
45 void
47 const server::http::connection_t& conn,
48 spdlog::level::level_enum level,
49 fmt::format_string<Args...> fmt,
50 Args&&... args
51 )
52 {
53 std::visit(
54 [level, &fmt, ...args = std::forward<Args>(args)](const auto& c) mutable {
55 if (!c)
56 return;
57
58 if (c->logger())
59 c->logger()->log(level, fmt, std::forward<Args>(args)...);
60 },
61 conn
62 );
63 }
64
65} // namespace malloy
Definition: controller.hpp:32
void log(const server::http::connection_t &conn, spdlog::level::level_enum level, fmt::format_string< Args... > fmt, Args &&... args)
Definition: connection_t.hpp:46