OmniSciDB  a5dc49c757
 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:217

+ 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:217

+ 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:217

+ 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:217

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

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

267  {
268  log(logger::Severity::INFO, "stdlog");
269  logCallStack(logger::Severity::DEBUG1, "stacked_times");
270  if (query_state_) {
271  query_state_->setLogged(true);
272  }
273  if (session_info_) {
274  session_info_->update_last_used_time();
275  }
276 }
void logCallStack(logger::Severity, char const *label)
Definition: QueryState.cpp:255
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:217

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

217  {
218  if (logger::fast_logging_check(severity)) {
219  std::stringstream ss;
221  ss << tlids.request_id_ << ' ' << tlids.thread_id_ << ' ' << file_ << ':' << line_
222  << ' ' << label << ' ' << func_ << ' ' << match_ << ' '
223  << duration<std::chrono::milliseconds>() << ' ';
224  if (session_info_) {
225  ss << SessionInfoFormatter{*session_info_} << ' ';
226  } else if (query_state_ && query_state_->getSessionData()) {
227  ss << *query_state_->getSessionData() << ' ';
228  } else {
229  ss << " "; // 3 spaces for 3 empty strings
230  }
231  auto const& nv = name_value_pairs_;
232  if (nv.empty() && (!query_state_ || query_state_->emptyLog())) {
233  ss << ' '; // 1 space for final empty names/values arrays
234  } else {
235  // All values are logged after all names, so separate values stream is needed.
236  std::stringstream values;
237  unsigned nvalues = 0;
238  if (query_state_ && !query_state_->getQueryStr().empty()) {
239  ss << (nvalues ? ',' : '{') << std::quoted("query_str", '"', '"');
240  values << (nvalues++ ? ',' : '{')
241  << std::quoted(hide_sensitive_data_from_query(query_state_->getQueryStr()),
242  '"',
243  '"');
244  }
245  for (auto itr = nv.cbegin(); itr != nv.cend(); ++itr) {
246  ss << (nvalues ? ',' : '{') << std::quoted(*itr, '"', '"');
247  values << (nvalues++ ? ',' : '{') << std::quoted(*++itr, '"', '"');
248  }
249  ss << "} " << values.rdbuf() << '}';
250  }
251  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
252  }
253 }
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:882

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

255  {
256  if (logger::fast_logging_check(severity) && query_state_) {
257  std::stringstream ss;
259  ss << tlids.request_id_ << ' ' << tlids.thread_id_ << ' ' << file_ << ':' << line_
260  << ' ' << label << ' ' << func_ << ' ' << match_ << " total time "
261  << duration<std::chrono::milliseconds>() << " ms";
262  query_state_->logCallStack(ss);
263  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
264  }
265 }
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:882

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

References query_state_.

Referenced by DBHandler::get_table_details_impl().

278  {
279  query_state_ = std::move(query_state);
280 }
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 282 of file QueryState.cpp.

References session_info_.

Referenced by DBHandler::connect_impl().

283  {
284  session_info_ = std::move(session_info);
285 }
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  {"clear_gpu_memory", logger::Severity::INFO},
212  {"clear_cpu_memory", logger::Severity::INFO}};
213  auto const itr = map.find(func);
214  return itr == map.cend() ? defaultSeverity : itr->second;
215 }
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: