28 #ifndef WEBSOCKETPP_LOGGER_BASIC_HPP 29 #define WEBSOCKETPP_LOGGER_BASIC_HPP 58 template <
typename concurrency,
typename names>
63 : m_static_channels(0xffffffff)
64 , m_dynamic_channels(0)
68 : m_static_channels(0xffffffff)
69 , m_dynamic_channels(0)
74 : m_static_channels(c)
75 , m_dynamic_channels(0)
79 : m_static_channels(c)
80 , m_dynamic_channels(0)
88 : m_static_channels(other.m_static_channels)
89 , m_dynamic_channels(other.m_dynamic_channels)
93 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 96 #endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 98 #ifdef _WEBSOCKETPP_MOVE_SEMANTICS_ 101 : m_static_channels(other.m_static_channels)
102 , m_dynamic_channels(other.m_dynamic_channels)
106 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 109 #endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 111 #endif // _WEBSOCKETPP_MOVE_SEMANTICS_ 118 if (channels == names::none) {
124 m_dynamic_channels |= (channels & m_static_channels);
129 m_dynamic_channels &= ~channels;
140 *m_out <<
"[" << timestamp <<
"] " 141 <<
"[" << names::channel_name(channel) <<
"] " 154 *m_out <<
"[" << timestamp <<
"] " 155 <<
"[" << names::channel_name(channel) <<
"] " 161 return ((channel & m_static_channels) != 0);
165 return ((channel & m_dynamic_channels) != 0);
179 static std::ostream & timestamp(std::ostream & os) {
180 std::time_t t = std::time(NULL);
182 #ifdef _WEBSOCKETPP_PUTTIME_ 183 return os << std::put_time(<,
"%Y-%m-%d %H:%M:%S");
184 #else // Falls back to strftime, which requires a temporary copy of the string. 186 size_t result = std::strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S",<);
187 return os << (result == 0 ?
"Unknown" : buffer);
191 level const m_static_channels;
192 level m_dynamic_channels;
193 std::ostream * m_out;
199 #endif // WEBSOCKETPP_LOGGER_BASIC_HPP std::tm localtime(std::time_t const &time)
Thread safe cross platform localtime.
void clear_channels(level channels)
bool dynamic_test(level channel)
uint32_t value
Type of a channel type hint value.
static value const access
Access log.
void write(level channel, char const *msg)
Write a cstring message to the given channel.
concurrency::scoped_lock_type scoped_lock_type
void write(level channel, std::string const &msg)
Write a string message to the given channel.
#define _WEBSOCKETPP_CONSTEXPR_TOKEN_
static value const error
Error log.
Basic logger that outputs to an ostream.
Namespace for the WebSocket++ project.
void set_ostream(std::ostream *out=&std::cout)
concurrency::mutex_type mutex_type
uint32_t level
Type of a channel package.
void set_channels(level channels)
_WEBSOCKETPP_CONSTEXPR_TOKEN_ bool static_test(level channel) const