OmniSciDB  b24e664e58
 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 252 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 260 of file QueryState.h.

References logger::DEBUG1, and log().

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

+ 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 271 of file QueryState.h.

References logger::DEBUG1, and log().

277  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
278  , session_info_(std::move(session_info))
279  , query_state_(std::move(query_state)) {
280  log(logger::Severity::DEBUG1, "stdlog_begin");
281  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:240
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:253
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:254
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:165

+ 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 284 of file QueryState.h.

References logger::DEBUG1, and log().

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

+ 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 294 of file QueryState.h.

References logger::DEBUG1, and log().

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

+ 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 211 of file QueryState.cpp.

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

211  {
212  log(logger::Severity::INFO, "stdlog");
213  logCallStack(logger::Severity::DEBUG1, "stacked_times");
214  if (query_state_) {
215  query_state_->setLogged(true);
216  }
217  if (session_info_) {
218  session_info_->update_last_used_time();
219  }
220 }
void logCallStack(logger::Severity, char const *label)
Definition: QueryState.cpp:201
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:253
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:254
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:165

+ 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 302 of file QueryState.h.

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

Referenced by MapDHandler::connect_impl().

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

+ 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 309 of file QueryState.h.

References query_state::StdLogData::start_.

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

Definition at line 128 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::get_tables_impl().

129  {
130  return session_info_;
131 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:253

+ Here is the caller graph for this function:

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

Definition at line 133 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::get_table_details_impl().

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

+ Here is the caller graph for this function:

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

Definition at line 165 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().

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

+ 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 201 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().

201  {
202  if (logger::fast_logging_check(severity) && query_state_) {
203  std::stringstream ss;
204  ss << file_ << ':' << line_ << ' ' << label << ' ' << func_ << ' ' << match_
205  << " total time " << duration<std::chrono::milliseconds>() << " ms";
206  query_state_->logCallStack(ss);
207  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
208  }
209 }
unsigned const line_
Definition: QueryState.h:234
std::string const file_
Definition: QueryState.h:233
bool fast_logging_check(Channel)
Definition: Logger.h:171
int64_t const match_
Definition: QueryState.h:237
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:254
char const *const func_
Definition: QueryState.h:235

+ 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 222 of file QueryState.cpp.

References query_state_.

Referenced by MapDHandler::get_table_details_impl().

222  {
223  query_state_ = std::move(query_state);
224 }
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:254

+ Here is the caller graph for this function:

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

Definition at line 226 of file QueryState.cpp.

References session_info_.

Referenced by MapDHandler::connect_impl().

227  {
228  session_info_ = std::move(session_info);
229 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:253

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 254 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 253 of file QueryState.h.

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


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