OmniSciDB  49c0524acb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
query_state::StdLog Class Reference

#include <QueryState.h>

+ Inheritance diagram for query_state::StdLog:
+ Collaboration diagram for query_state::StdLog:

Public Member Functions

template<typename... Pairs>
 StdLog (char const *file, unsigned line, char const *func, std::shared_ptr< Catalog_Namespace::SessionInfo > session_info, Pairs &&...pairs)
 
template<typename... Pairs>
 StdLog (char const *file, unsigned line, char const *func, std::shared_ptr< Catalog_Namespace::SessionInfo > session_info, std::shared_ptr< QueryState > query_state, Pairs &&...pairs)
 
template<typename... Pairs>
 StdLog (char const *file, unsigned line, char const *func, std::shared_ptr< QueryState > query_state, Pairs &&...pairs)
 
template<typename... Pairs>
 StdLog (char const *file, unsigned line, char const *func, Pairs &&...pairs)
 
 StdLog (StdLog const &)=delete
 
 StdLog (StdLog &&)=default
 
 ~StdLog ()
 
template<typename... Pairs>
void appendNameValuePairs (Pairs &&...pairs)
 
template<typename Units = std::chrono::milliseconds>
Units::rep duration () const
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const > 
getConstSessionInfo () const
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
getSessionInfo () const
 
void setQueryState (std::shared_ptr< QueryState >)
 
void setSessionInfo (std::shared_ptr< Catalog_Namespace::SessionInfo >)
 

Private Member Functions

void log (logger::Severity, char const *label)
 
void logCallStack (logger::Severity, char const *label)
 

Private Attributes

std::shared_ptr
< Catalog_Namespace::SessionInfo
session_info_
 
std::shared_ptr< QueryStatequery_state_
 

Additional Inherited Members

- Protected Member Functions inherited from query_state::StdLogData
template<typename... Pairs>
 StdLogData (char const *file, unsigned line, char const *func, Pairs &&...pairs)
 
- Protected Attributes inherited from query_state::StdLogData
std::string const file_
 
unsigned const line_
 
char const *const func_
 
Clock::time_point const start_
 
int64_t const match_
 
std::list< std::string > name_value_pairs_
 
- Static Protected Attributes inherited from query_state::StdLogData
static std::atomic< int64_t > s_match {0}
 

Detailed Description

Definition at line 250 of file QueryState.h.

Constructor & Destructor Documentation

template<typename... Pairs>
query_state::StdLog::StdLog ( char const *  file,
unsigned  line,
char const *  func,
std::shared_ptr< Catalog_Namespace::SessionInfo session_info,
Pairs &&...  pairs 
)
inline

Definition at line 258 of file QueryState.h.

References logger::DEBUG1, and log().

263  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
264  , session_info_(std::move(session_info)) {
265  log(logger::Severity::DEBUG1, "stdlog_begin");
266  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:238
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:162

+ Here is the call graph for this function:

template<typename... Pairs>
query_state::StdLog::StdLog ( char const *  file,
unsigned  line,
char const *  func,
std::shared_ptr< Catalog_Namespace::SessionInfo session_info,
std::shared_ptr< QueryState query_state,
Pairs &&...  pairs 
)
inline

Definition at line 269 of file QueryState.h.

References logger::DEBUG1, and log().

275  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
276  , session_info_(std::move(session_info))
277  , query_state_(std::move(query_state)) {
278  log(logger::Severity::DEBUG1, "stdlog_begin");
279  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:238
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:162

+ Here is the call graph for this function:

template<typename... Pairs>
query_state::StdLog::StdLog ( char const *  file,
unsigned  line,
char const *  func,
std::shared_ptr< QueryState query_state,
Pairs &&...  pairs 
)
inline

Definition at line 282 of file QueryState.h.

References logger::DEBUG1, and log().

287  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
288  , query_state_(std::move(query_state)) {
289  log(logger::Severity::DEBUG1, "stdlog_begin");
290  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:238
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:162

+ Here is the call graph for this function:

template<typename... Pairs>
query_state::StdLog::StdLog ( char const *  file,
unsigned  line,
char const *  func,
Pairs &&...  pairs 
)
inline

Definition at line 292 of file QueryState.h.

References logger::DEBUG1, and log().

293  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...) {
294  log(logger::Severity::DEBUG1, "stdlog_begin");
295  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:238
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:162

+ Here is the call graph for this function:

query_state::StdLog::StdLog ( StdLog const &  )
delete
query_state::StdLog::StdLog ( StdLog &&  )
default
query_state::StdLog::~StdLog ( )

Definition at line 207 of file QueryState.cpp.

References logger::DEBUG1, logger::INFO, log(), logCallStack(), query_state_, and session_info_.

207  {
208  log(logger::Severity::INFO, "stdlog");
209  logCallStack(logger::Severity::DEBUG1, "stacked_times");
210  if (query_state_) {
211  query_state_->set_logged(true);
212  }
213  if (session_info_) {
214  session_info_->update_last_used_time();
215  }
216 }
void logCallStack(logger::Severity, char const *label)
Definition: QueryState.cpp:197
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:162

+ Here is the call graph for this function:

Member Function Documentation

template<typename... Pairs>
void query_state::StdLog::appendNameValuePairs ( Pairs &&...  pairs)
inline

Definition at line 300 of file QueryState.h.

References query_state::StdLogData::name_value_pairs_, and to_string().

Referenced by MapDHandler::connect_impl().

300  {
301  static_assert(sizeof...(Pairs) % 2 == 0,
302  "appendNameValuePairs() requires an even number of parameters.");
303  name_value_pairs_.splice(name_value_pairs_.cend(),
304  {to_string(std::forward<Pairs>(pairs))...});
305  }
std::string to_string(char const *&&v)
std::list< std::string > name_value_pairs_
Definition: QueryState.h:236

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename Units = std::chrono::milliseconds>
Units::rep query_state::StdLog::duration ( ) const
inline

Definition at line 307 of file QueryState.h.

References query_state::StdLogData::start_.

307  {
308  return std::chrono::duration_cast<Units>(Clock::now() - start_).count();
309  }
Clock::time_point const start_
Definition: QueryState.h:234
std::shared_ptr< Catalog_Namespace::SessionInfo const > query_state::StdLog::getConstSessionInfo ( ) const

Definition at line 132 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::get_tables_impl().

133  {
134  return session_info_;
135 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251

+ Here is the caller graph for this function:

std::shared_ptr< Catalog_Namespace::SessionInfo > query_state::StdLog::getSessionInfo ( ) const

Definition at line 137 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::get_table_details_impl().

137  {
138  return session_info_;
139 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251

+ Here is the caller graph for this function:

void query_state::StdLog::log ( logger::Severity  severity,
char const *  label 
)
private

Definition at line 162 of file QueryState.cpp.

References logger::fast_logging_check(), query_state::StdLogData::file_, query_state::StdLogData::func_, hide_sensitive_data_from_query(), query_state::StdLogData::line_, query_state::StdLogData::match_, query_state::StdLogData::name_value_pairs_, query_state_, and session_info_.

Referenced by StdLog(), and ~StdLog().

162  {
163  if (logger::fast_logging_check(severity)) {
164  std::stringstream ss;
165  ss << file_ << ':' << line_ << ' ' << label << ' ' << func_ << ' ' << match_ << ' '
166  << duration<std::chrono::milliseconds>() << ' ';
167  if (session_info_) {
168  ss << SessionInfoFormatter{*session_info_} << ' ';
169  } else {
170  ss << " "; // 3 spaces for 3 empty strings
171  }
172  auto const& nv = name_value_pairs_;
173  if (nv.empty() && (!query_state_ || query_state_->empty_log())) {
174  ss << ' '; // 1 space for final empty names/values arrays
175  } else {
176  // All values are logged after all names, so separate values stream is needed.
177  std::stringstream values;
178  unsigned nvalues = 0;
179  if (query_state_ && !query_state_->get_query_str().empty()) {
180  ss << (nvalues ? ',' : '{') << std::quoted("query_str", '"', '"');
181  values << (nvalues++ ? ',' : '{')
182  << std::quoted(
184  '"',
185  '"');
186  }
187  for (auto itr = nv.cbegin(); itr != nv.cend(); ++itr) {
188  ss << (nvalues ? ',' : '{') << std::quoted(*itr, '"', '"');
189  values << (nvalues++ ? ',' : '{') << std::quoted(*++itr, '"', '"');
190  }
191  ss << "} " << values.rdbuf() << '}';
192  }
193  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
194  }
195 }
std::string hide_sensitive_data_from_query(std::string const &query_str)
unsigned const line_
Definition: QueryState.h:232
std::string const file_
Definition: QueryState.h:231
std::list< std::string > name_value_pairs_
Definition: QueryState.h:236
bool fast_logging_check(Channel)
Definition: Logger.h:168
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251
int64_t const match_
Definition: QueryState.h:235
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252
char const *const func_
Definition: QueryState.h:233

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void query_state::StdLog::logCallStack ( logger::Severity  severity,
char const *  label 
)
private

Definition at line 197 of file QueryState.cpp.

References logger::fast_logging_check(), query_state::StdLogData::file_, query_state::StdLogData::func_, query_state::StdLogData::line_, query_state::StdLogData::match_, and query_state_.

Referenced by ~StdLog().

197  {
198  if (logger::fast_logging_check(severity) && query_state_) {
199  std::stringstream ss;
200  ss << file_ << ':' << line_ << ' ' << label << ' ' << func_ << ' ' << match_
201  << " total time " << duration<std::chrono::milliseconds>() << " ms";
202  query_state_->logCallStack(ss);
203  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
204  }
205 }
unsigned const line_
Definition: QueryState.h:232
std::string const file_
Definition: QueryState.h:231
bool fast_logging_check(Channel)
Definition: Logger.h:168
int64_t const match_
Definition: QueryState.h:235
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252
char const *const func_
Definition: QueryState.h:233

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void query_state::StdLog::setQueryState ( std::shared_ptr< QueryState query_state)

Definition at line 218 of file QueryState.cpp.

References query_state_.

Referenced by MapDHandler::get_table_details_impl().

218  {
219  query_state_ = std::move(query_state);
220 }
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:252

+ Here is the caller graph for this function:

void query_state::StdLog::setSessionInfo ( std::shared_ptr< Catalog_Namespace::SessionInfo session_info)

Definition at line 222 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::connect_impl().

223  {
224  session_info_ = std::move(session_info);
225 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:251

+ Here is the caller graph for this function:

Member Data Documentation

std::shared_ptr<QueryState> query_state::StdLog::query_state_
private

Definition at line 252 of file QueryState.h.

Referenced by log(), logCallStack(), setQueryState(), and ~StdLog().

std::shared_ptr<Catalog_Namespace::SessionInfo> query_state::StdLog::session_info_
private

Definition at line 251 of file QueryState.h.

Referenced by getConstSessionInfo(), getSessionInfo(), log(), setSessionInfo(), and ~StdLog().


The documentation for this class was generated from the following files: