OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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)
 

Static Private Member Functions

static logger::Severity stdlogBeginSeverity (char const *func)
 

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 261 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 270 of file QueryState.h.

References log(), and stdlogBeginSeverity().

275  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
276  , session_info_(std::move(session_info)) {
277  log(stdlogBeginSeverity(func), "stdlog_begin");
278  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:249
static logger::Severity stdlogBeginSeverity(char const *func)
Definition: QueryState.cpp:190
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262
tuple line
Definition: parse_ast.py:10
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:215

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

References log(), and stdlogBeginSeverity().

287  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
288  , session_info_(std::move(session_info))
289  , query_state_(std::move(query_state)) {
290  log(stdlogBeginSeverity(func), "stdlog_begin");
291  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:249
static logger::Severity stdlogBeginSeverity(char const *func)
Definition: QueryState.cpp:190
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262
tuple line
Definition: parse_ast.py:10
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:215

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

References log(), and stdlogBeginSeverity().

299  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...)
300  , query_state_(std::move(query_state)) {
301  log(stdlogBeginSeverity(func), "stdlog_begin");
302  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:249
static logger::Severity stdlogBeginSeverity(char const *func)
Definition: QueryState.cpp:190
tuple line
Definition: parse_ast.py:10
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:215

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

References log(), and stdlogBeginSeverity().

305  : StdLogData(file, line, func, std::forward<Pairs>(pairs)...) {
306  log(stdlogBeginSeverity(func), "stdlog_begin");
307  }
StdLogData(char const *file, unsigned line, char const *func, Pairs &&...pairs)
Definition: QueryState.h:249
static logger::Severity stdlogBeginSeverity(char const *func)
Definition: QueryState.cpp:190
tuple line
Definition: parse_ast.py:10
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:215

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

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

265  {
266  log(logger::Severity::INFO, "stdlog");
267  logCallStack(logger::Severity::DEBUG1, "stacked_times");
268  if (query_state_) {
269  query_state_->setLogged(true);
270  }
271  if (session_info_) {
272  session_info_->update_last_used_time();
273  }
274 }
void logCallStack(logger::Severity, char const *label)
Definition: QueryState.cpp:253
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263
void log(logger::Severity, char const *label)
Definition: QueryState.cpp:215

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

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

Referenced by DBHandler::connect_impl().

312  {
313  static_assert(sizeof...(Pairs) % 2 == 0,
314  "appendNameValuePairs() requires an even number of parameters.");
315  name_value_pairs_.splice(name_value_pairs_.cend(),
316  {to_string(std::forward<Pairs>(pairs))...});
317  }
std::string to_string(char const *&&v)
std::list< std::string > name_value_pairs_
Definition: QueryState.h:247

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

References query_state::StdLogData::start_.

319  {
320  return std::chrono::duration_cast<Units>(Clock::now() - start_).count();
321  }
Clock::time_point const start_
Definition: QueryState.h:245
std::shared_ptr< Catalog_Namespace::SessionInfo const > query_state::StdLog::getConstSessionInfo ( ) const

Definition at line 150 of file QueryState.cpp.

References session_info_.

Referenced by DBHandler::connect_impl(), and DBHandler::get_completion_hints_unsorted().

151  {
152  return session_info_;
153 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262

+ Here is the caller graph for this function:

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

Definition at line 155 of file QueryState.cpp.

References session_info_.

Referenced by DBHandler::get_table_details_impl().

155  {
156  return session_info_;
157 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262

+ Here is the caller graph for this function:

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

Definition at line 215 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_, logger::ThreadLocalIds::request_id_, session_info_, logger::ThreadLocalIds::thread_id_, and logger::thread_local_ids().

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

215  {
216  if (logger::fast_logging_check(severity)) {
217  std::stringstream ss;
219  ss << tlids.request_id_ << ' ' << tlids.thread_id_ << ' ' << file_ << ':' << line_
220  << ' ' << label << ' ' << func_ << ' ' << match_ << ' '
221  << duration<std::chrono::milliseconds>() << ' ';
222  if (session_info_) {
223  ss << SessionInfoFormatter{*session_info_} << ' ';
224  } else if (query_state_ && query_state_->getSessionData()) {
225  ss << *query_state_->getSessionData() << ' ';
226  } else {
227  ss << " "; // 3 spaces for 3 empty strings
228  }
229  auto const& nv = name_value_pairs_;
230  if (nv.empty() && (!query_state_ || query_state_->emptyLog())) {
231  ss << ' '; // 1 space for final empty names/values arrays
232  } else {
233  // All values are logged after all names, so separate values stream is needed.
234  std::stringstream values;
235  unsigned nvalues = 0;
236  if (query_state_ && !query_state_->getQueryStr().empty()) {
237  ss << (nvalues ? ',' : '{') << std::quoted("query_str", '"', '"');
238  values << (nvalues++ ? ',' : '{')
239  << std::quoted(hide_sensitive_data_from_query(query_state_->getQueryStr()),
240  '"',
241  '"');
242  }
243  for (auto itr = nv.cbegin(); itr != nv.cend(); ++itr) {
244  ss << (nvalues ? ',' : '{') << std::quoted(*itr, '"', '"');
245  values << (nvalues++ ? ',' : '{') << std::quoted(*++itr, '"', '"');
246  }
247  ss << "} " << values.rdbuf() << '}';
248  }
249  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
250  }
251 }
std::string hide_sensitive_data_from_query(std::string const &query_str)
unsigned const line_
Definition: QueryState.h:243
std::string const file_
Definition: QueryState.h:242
RequestId request_id_
Definition: Logger.h:137
std::list< std::string > name_value_pairs_
Definition: QueryState.h:247
bool fast_logging_check(Channel)
Definition: Logger.h:265
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262
int64_t const match_
Definition: QueryState.h:246
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263
char const *const func_
Definition: QueryState.h:244
ThreadId thread_id_
Definition: Logger.h:138
ThreadLocalIds thread_local_ids()
Definition: Logger.cpp:874

+ 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 253 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_, query_state_, logger::ThreadLocalIds::request_id_, logger::ThreadLocalIds::thread_id_, and logger::thread_local_ids().

Referenced by ~StdLog().

253  {
254  if (logger::fast_logging_check(severity) && query_state_) {
255  std::stringstream ss;
257  ss << tlids.request_id_ << ' ' << tlids.thread_id_ << ' ' << file_ << ':' << line_
258  << ' ' << label << ' ' << func_ << ' ' << match_ << " total time "
259  << duration<std::chrono::milliseconds>() << " ms";
260  query_state_->logCallStack(ss);
261  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
262  }
263 }
unsigned const line_
Definition: QueryState.h:243
std::string const file_
Definition: QueryState.h:242
RequestId request_id_
Definition: Logger.h:137
bool fast_logging_check(Channel)
Definition: Logger.h:265
int64_t const match_
Definition: QueryState.h:246
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263
char const *const func_
Definition: QueryState.h:244
ThreadId thread_id_
Definition: Logger.h:138
ThreadLocalIds thread_local_ids()
Definition: Logger.cpp:874

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

References query_state_.

Referenced by DBHandler::get_table_details_impl().

276  {
277  query_state_ = std::move(query_state);
278 }
std::shared_ptr< QueryState > query_state_
Definition: QueryState.h:263

+ Here is the caller graph for this function:

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

Definition at line 280 of file QueryState.cpp.

References session_info_.

Referenced by DBHandler::connect_impl().

281  {
282  session_info_ = std::move(session_info);
283 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
Definition: QueryState.h:262

+ Here is the caller graph for this function:

logger::Severity query_state::StdLog::stdlogBeginSeverity ( char const *  func)
staticprivate

Definition at line 190 of file QueryState.cpp.

References logger::DEBUG1, and logger::INFO.

Referenced by StdLog().

190  {
191  logger::Severity const defaultSeverity = logger::Severity::DEBUG1;
192  static std::unordered_map<std::string_view, logger::Severity> const map{
193  {"connect", logger::Severity::INFO},
194  {"disconnect", logger::Severity::INFO},
195  {"switch_database", logger::Severity::INFO},
196  {"clone_session", logger::Severity::INFO},
197  {"get_tables_meta", logger::Severity::INFO},
198  {"get_table_details", logger::Severity::INFO},
199  {"sql_execute", logger::Severity::INFO},
200  {"sql_execute_df", logger::Severity::INFO},
201  {"sql_execute_gdf", logger::Severity::INFO},
202  {"sql_validate", logger::Severity::INFO},
203  {"render_vega", logger::Severity::INFO},
204  {"get_result_row_for_pixel", logger::Severity::INFO},
205  {"check_table_consistency", logger::Severity::INFO},
206  {"start_query", logger::Severity::INFO},
207  {"execute_query_step", logger::Severity::INFO},
208  {"broadcast_serialized_rows", logger::Severity::INFO},
209  {"start_render_query", logger::Severity::INFO},
210  {"execute_next_render_step", logger::Severity::INFO}};
211  auto const itr = map.find(func);
212  return itr == map.cend() ? defaultSeverity : itr->second;
213 }
Severity
Definition: Logger.h:103

+ Here is the caller graph for this function:

Member Data Documentation

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

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

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


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