OmniSciDB  c07336695a
LogSession Class Reference

#include <MapDHandler.h>

+ Inheritance diagram for LogSession:
+ Collaboration diagram for LogSession:

Public Member Functions

template<typename... Pairs>
 LogSession (MapDHandler &mh, SessionMap::mapped_type &session_ptr, char const *file, size_t line, char const *func, Pairs &&... pairs)
 
template<typename... Pairs>
 LogSession (MapDHandler &mh, TSessionId const &session_id, char const *file, size_t line, char const *func, Pairs &&... pairs)
 
 ~LogSession ()
 
template<typename... Pairs>
void append_name_value_pairs (Pairs &&... pairs)
 
template<typename Units = std::chrono::milliseconds>
Units::rep duration () const
 
void set_session (SessionMap::mapped_type &session_ptr)
 

Private Member Functions

template<typename... Pairs>
 LogSession (char const *file, size_t line, char const *func, Pairs &&... pairs)
 
void stdlog (logger::Severity, char const *label)
 
void update_session_last_used_duration ()
 

Private Attributes

std::string const file_
 
size_t const line_
 
char const *const func_
 
std::list< std::string > name_value_pairs_
 
std::chrono::steady_clock::time_point const start_
 
std::shared_ptr< Catalog_Namespace::SessionInfosession_ptr_
 
int64_t const match_
 

Static Private Attributes

static std::atomic< int64_t > s_match {0}
 

Detailed Description

Definition at line 745 of file MapDHandler.h.

Constructor & Destructor Documentation

◆ LogSession() [1/3]

template<typename... Pairs>
LogSession::LogSession ( char const *  file,
size_t  line,
char const *  func,
Pairs &&...  pairs 
)
inlineprivate

Definition at line 755 of file MapDHandler.h.

References to_string().

756  : file_(boost::filesystem::path(file).filename().string())
757  , line_(line)
758  , func_(func)
759  , name_value_pairs_{to_string(std::forward<Pairs>(pairs))...}
760  , start_(std::chrono::steady_clock::now())
761  , match_(s_match++) {
762  static_assert(sizeof...(Pairs) % 2 == 0,
763  "LogSession() requires an even number of name/value parameters.");
764  }
static std::atomic< int64_t > s_match
Definition: MapDHandler.h:752
std::string const file_
Definition: MapDHandler.h:746
std::string to_string(char const *&&v)
std::list< std::string > name_value_pairs_
Definition: MapDHandler.h:749
char const *const func_
Definition: MapDHandler.h:748
size_t const line_
Definition: MapDHandler.h:747
int64_t const match_
Definition: MapDHandler.h:753
std::chrono::steady_clock::time_point const start_
Definition: MapDHandler.h:750
+ Here is the call graph for this function:

◆ LogSession() [2/3]

template<typename... Pairs>
LogSession::LogSession ( MapDHandler mh,
SessionMap::mapped_type &  session_ptr,
char const *  file,
size_t  line,
char const *  func,
Pairs &&...  pairs 
)
inline

Definition at line 770 of file MapDHandler.h.

References logger::DEBUG1.

776  : LogSession(file, line, func, std::forward<Pairs>(pairs)...) {
777  session_ptr_ = session_ptr;
778  stdlog(logger::Severity::DEBUG1, "stdlog_begin");
779  }
LogSession(char const *file, size_t line, char const *func, Pairs &&... pairs)
Definition: MapDHandler.h:755
void stdlog(logger::Severity, char const *label)
std::shared_ptr< Catalog_Namespace::SessionInfo > session_ptr_
Definition: MapDHandler.h:751

◆ LogSession() [3/3]

template<typename... Pairs>
LogSession::LogSession ( MapDHandler mh,
TSessionId const &  session_id,
char const *  file,
size_t  line,
char const *  func,
Pairs &&...  pairs 
)
inline

Definition at line 781 of file MapDHandler.h.

References logger::DEBUG1, and MapDHandler::get_session_ptr().

787  : LogSession(file, line, func, std::forward<Pairs>(pairs)...) {
788  session_ptr_ = mh.get_session_ptr(session_id);
789  stdlog(logger::Severity::DEBUG1, "stdlog_begin");
790  }
LogSession(char const *file, size_t line, char const *func, Pairs &&... pairs)
Definition: MapDHandler.h:755
std::shared_ptr< Catalog_Namespace::SessionInfo > get_session_ptr(const TSessionId &session_id)
void stdlog(logger::Severity, char const *label)
std::shared_ptr< Catalog_Namespace::SessionInfo > session_ptr_
Definition: MapDHandler.h:751
+ Here is the call graph for this function:

◆ ~LogSession()

LogSession::~LogSession ( )

Definition at line 5600 of file MapDHandler.cpp.

References logger::INFO.

5600  {
5602  stdlog(logger::Severity::INFO, "stdlog");
5603 }
void stdlog(logger::Severity, char const *label)
void update_session_last_used_duration()

Member Function Documentation

◆ append_name_value_pairs()

template<typename... Pairs>
void LogSession::append_name_value_pairs ( Pairs &&...  pairs)
inline

Definition at line 793 of file MapDHandler.h.

References to_string().

Referenced by MapDHandler::connect_impl().

793  {
794  static_assert(sizeof...(Pairs) % 2 == 0,
795  "append_name_value_pairs() requires an even number of parameters.");
796  name_value_pairs_.splice(name_value_pairs_.cend(),
797  {to_string(std::forward<Pairs>(pairs))...});
798  }
std::string to_string(char const *&&v)
std::list< std::string > name_value_pairs_
Definition: MapDHandler.h:749
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duration()

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

Definition at line 800 of file MapDHandler.h.

800  {
801  using namespace std::chrono;
802  return duration_cast<Units>(steady_clock::now() - start_).count();
803  }
std::chrono::steady_clock::time_point const start_
Definition: MapDHandler.h:750

◆ set_session()

void LogSession::set_session ( SessionMap::mapped_type &  session_ptr)

Definition at line 5605 of file MapDHandler.cpp.

References MapDHandler::get_device_parameters().

Referenced by MapDHandler::connect_impl().

5605  {
5606  session_ptr_ = session_ptr;
5607 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_ptr_
Definition: MapDHandler.h:751
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stdlog()

void LogSession::stdlog ( logger::Severity  severity,
char const *  label 
)
private

Definition at line 5554 of file MapDHandler.cpp.

References logger::fast_logging_check().

5554  {
5555  if (logger::fast_logging_check(severity)) {
5556  std::stringstream ss;
5557  ss << file_ << ':' << line_ << ' ' << label << ' ' << func_ << ' ' << match_ << ' '
5558  << duration<std::chrono::milliseconds>() << ' ';
5559  if (session_ptr_) {
5560  std::string const& dbname = session_ptr_->getCatalog().getCurrentDB().dbName;
5561  if (dbname.find_first_of(" \"") == std::string::npos) {
5562  ss << dbname << ' ';
5563  } else {
5564  ss << std::quoted(dbname, '"', '"') << ' ';
5565  }
5566  std::string const& username = session_ptr_->get_currentUser().userName;
5567  if (username.find_first_of(" \"") == std::string::npos) {
5568  ss << username << ' ';
5569  } else {
5570  ss << std::quoted(username, '"', '"') << ' ';
5571  }
5572  ss << session_ptr_->get_public_session_id() << ' ';
5573  } else {
5574  ss << " "; // 3 spaces for 3 empty strings
5575  }
5576  auto const& nv = name_value_pairs_;
5577  if (nv.empty()) {
5578  ss << ' '; // 1 space for final empty names/values arrays
5579  } else {
5580  ss << '{' << std::quoted(*nv.cbegin(), '"', '"'); // names
5581  for (auto itr = std::next(nv.cbegin(), 2); itr != nv.cend(); std::advance(itr, 2)) {
5582  ss << ',' << std::quoted(*itr, '"', '"');
5583  }
5584  ss << "} {" << std::quoted(*std::next(nv.cbegin()), '"', '"'); // values
5585  for (auto itr = std::next(nv.cbegin(), 2); itr != nv.cend(); std::advance(itr, 2)) {
5586  ss << ',' << std::quoted(*std::next(itr), '"', '"');
5587  }
5588  ss << '}';
5589  }
5590  BOOST_LOG_SEV(logger::gSeverityLogger::get(), severity) << ss.rdbuf();
5591  }
5592 }
std::string const file_
Definition: MapDHandler.h:746
std::list< std::string > name_value_pairs_
Definition: MapDHandler.h:749
bool fast_logging_check(Channel)
Definition: Logger.h:168
char const *const func_
Definition: MapDHandler.h:748
std::shared_ptr< Catalog_Namespace::SessionInfo > session_ptr_
Definition: MapDHandler.h:751
size_t const line_
Definition: MapDHandler.h:747
int64_t const match_
Definition: MapDHandler.h:753
+ Here is the call graph for this function:

◆ update_session_last_used_duration()

void LogSession::update_session_last_used_duration ( )
private

Definition at line 5594 of file MapDHandler.cpp.

5594  {
5595  if (session_ptr_) {
5596  session_ptr_->update_last_used_time();
5597  }
5598 }
std::shared_ptr< Catalog_Namespace::SessionInfo > session_ptr_
Definition: MapDHandler.h:751

Member Data Documentation

◆ file_

std::string const LogSession::file_
private

Definition at line 746 of file MapDHandler.h.

◆ func_

char const* const LogSession::func_
private

Definition at line 748 of file MapDHandler.h.

◆ line_

size_t const LogSession::line_
private

Definition at line 747 of file MapDHandler.h.

◆ match_

int64_t const LogSession::match_
private

Definition at line 753 of file MapDHandler.h.

◆ name_value_pairs_

std::list<std::string> LogSession::name_value_pairs_
private

Definition at line 749 of file MapDHandler.h.

◆ s_match

std::atomic< int64_t > LogSession::s_match {0}
staticprivate

Definition at line 752 of file MapDHandler.h.

Referenced by MapDHandler::emergency_shutdown().

◆ session_ptr_

std::shared_ptr<Catalog_Namespace::SessionInfo> LogSession::session_ptr_
private

Definition at line 751 of file MapDHandler.h.

◆ start_

std::chrono::steady_clock::time_point const LogSession::start_
private

Definition at line 750 of file MapDHandler.h.


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