SOMHunter Core
sh::Logger Class Reference

Class responsible for all the logging for the given user (each user have it's own Logger.) More...

#include <logger.h>

Collaboration diagram for sh::Logger:

Public Member Functions

 Logger ()=delete
 
 Logger (const EvalServerSettings &settings, const UserContext *p_user_ctx, EvalServerClient *p_eval_server)
 
 ~Logger () noexcept
 
void poll ()
 Does periodic cleanup & log flush. More...
 
void log_search_context_switch (std::size_t dest_context_ID, size_t src_context_ID)
 
void log_submit (const VideoFrame frame, bool submit_result)
 Called whenever we want to log submit frame/shot into the server. More...
 
void log_query (const LogHash &hash, const Query &query) const
 Logs the provided query as a whole. More...
 
void log_canvas_query (const std::vector< TemporalQuery > &temp_queries, const std::vector< VideoFrame > *p_targets)
 
void log_rescore (const Query &prev_query, const Query &new_query)
 
void log_results (const DatasetFrames &_dataset_frames, const ScoreModel &scores, const std::set< FrameId > &likes, const UsedTools &used_tools, DisplayType disp_type, const std::vector< FrameId > &topn_imgs, const std::string &sentence_query, const size_t topn_frames_per_video, const size_t topn_frames_per_shot, const std::vector< bool > &dataset_parts_filter={ true, true })
 Called whenever we rescore. More...
 
void log_text_query_change (const std::string &query_sentence)
 
void log_canvas_query_change ()
 
void log_like (FrameId frame_ID)
 
void log_unlike (FrameId frame_ID)
 
void log_bookmark (FrameId frame_ID)
 
void log_unbookmark (FrameId frame_ID)
 
void log_show_som_display (const DatasetFrames &_dataset_frames, const std::vector< FrameId > &imgs)
 
void log_show_som_relocation_display (const DatasetFrames &_dataset_frames, const std::vector< FrameId > &imgs)
 
void log_show_random_display (const DatasetFrames &_dataset_frames, const std::vector< FrameId > &imgs)
 
void log_show_topn_display (const DatasetFrames &_dataset_frames, const std::vector< FrameId > &imgs)
 
void log_show_topn_context_display (const DatasetFrames &_dataset_frames, const std::vector< FrameId > &imgs)
 
void log_show_topknn_display (const DatasetFrames &_dataset_frames, FrameId frame_ID, const std::vector< FrameId > &imgs)
 
void log_show_detail_display (const DatasetFrames &_dataset_frames, FrameId frame_ID)
 
void log_show_video_replay (const DatasetFrames &_dataset_frames, FrameId frame_ID, float delta)
 
void log_scroll (const DatasetFrames &_dataset_frames, DisplayType from_disp_type, float dirY)
 
void log_reset_search ()
 
void submit_interaction_logs_buffer ()
 Sends the accumulated logs to the evaluation server (through _p_eval_server). More...
 
DebugLogStreamPtrs get_debug_streams ()
 
void clear_debug_streams ()
 

Private Member Functions

void log_bothlike (FrameId frame_ID, const std::string &type)
 
LogHash gen_action_hash (UnixTimestamp ts)
 
LogHash push_action (const std::string &action_name, const std::string &cat, const std::string &type, const std::string &value, nlohmann::json &&our_log_JSON={}, std::initializer_list< std::string > summary_keys={})
 
void write_result (const nlohmann::json &action_log)
 Writes the log into the local file. More...
 
void write_action (const nlohmann::json &action_log)
 Writes the log into the local file. More...
 
void write_summary (const nlohmann::json &log, const std::string &action_name, std::initializer_list< std::string > keys={})
 Writes the log into the local file. More...
 
std::string get_log_dir_queries () const
 
std::string get_results_log_filepath () const
 
std::string get_actions_log_filepath () const
 
std::string get_summary_log_filepath () const
 
std::lock_guard< std::mutex > get_exclusive_actions_lock () const
 

Private Attributes

const EvalServerSettings _logger_settings
 
const UserContext_p_user_ctx
 
EvalServerClient_p_eval_server
 
std::vector< nlohmann::json > _interactions_buffer
 
UnixTimestamp _last_interactions_submit_ts
 
std::ofstream _results_log_stream
 
std::ofstream _summary_log_stream
 
std::ofstream _actions_log_stream
 
std::vector< std::stringstream > _summary_streams
 
std::vector< std::stringstream > _actions_streams
 
std::vector< std::stringstream > _results_streams
 
bool _first_result { true }
 
bool _first_actions { true }
 
std::mutex _push_action_mtx
 

Detailed Description

Class responsible for all the logging for the given user (each user have it's own Logger.)

See also
class UserContext

Constructor & Destructor Documentation

◆ Logger() [1/2]

sh::Logger::Logger ( )
delete

◆ Logger() [2/2]

Logger::Logger ( const EvalServerSettings settings,
const UserContext p_user_ctx,
EvalServerClient p_eval_server 
)
Here is the call graph for this function:

◆ ~Logger()

Logger::~Logger ( )
noexcept
Here is the call graph for this function:

Member Function Documentation

◆ clear_debug_streams()

void sh::Logger::clear_debug_streams ( )
inline

◆ gen_action_hash()

LogHash Logger::gen_action_hash ( UnixTimestamp  ts)
private
Here is the call graph for this function:

◆ get_actions_log_filepath()

std::string Logger::get_actions_log_filepath ( ) const
private
Here is the call graph for this function:

◆ get_debug_streams()

DebugLogStreamPtrs sh::Logger::get_debug_streams ( )
inline

◆ get_exclusive_actions_lock()

std::lock_guard<std::mutex> sh::Logger::get_exclusive_actions_lock ( ) const
inlineprivate

◆ get_log_dir_queries()

std::string Logger::get_log_dir_queries ( ) const
private
Here is the call graph for this function:

◆ get_results_log_filepath()

std::string Logger::get_results_log_filepath ( ) const
private
Here is the call graph for this function:

◆ get_summary_log_filepath()

std::string Logger::get_summary_log_filepath ( ) const
private
Here is the call graph for this function:

◆ log_bookmark()

void Logger::log_bookmark ( FrameId  frame_ID)
Here is the call graph for this function:

◆ log_bothlike()

void Logger::log_bothlike ( FrameId  frame_ID,
const std::string &  type 
)
private
Here is the call graph for this function:

◆ log_canvas_query()

void Logger::log_canvas_query ( const std::vector< TemporalQuery > &  temp_queries,
const std::vector< VideoFrame > *  p_targets 
)
Here is the call graph for this function:

◆ log_canvas_query_change()

void Logger::log_canvas_query_change ( )
Here is the call graph for this function:

◆ log_like()

void Logger::log_like ( FrameId  frame_ID)
Here is the call graph for this function:

◆ log_query()

void Logger::log_query ( const LogHash hash,
const Query query 
) const

Logs the provided query as a whole.

Here is the call graph for this function:

◆ log_rescore()

void sh::Logger::log_rescore ( const Query prev_query,
const Query new_query 
)

◆ log_reset_search()

void Logger::log_reset_search ( )
Here is the call graph for this function:

◆ log_results()

void Logger::log_results ( const DatasetFrames _dataset_frames,
const ScoreModel scores,
const std::set< FrameId > &  likes,
const UsedTools used_tools,
DisplayType  disp_type,
const std::vector< FrameId > &  topn_imgs,
const std::string &  sentence_query,
const size_t  topn_frames_per_video,
const size_t  topn_frames_per_shot,
const std::vector< bool > &  dataset_parts_filter = { true, true } 
)

Called whenever we rescore.

Here is the call graph for this function:

◆ log_scroll()

void Logger::log_scroll ( const DatasetFrames _dataset_frames,
DisplayType  from_disp_type,
float  dirY 
)
Here is the call graph for this function:

◆ log_search_context_switch()

void Logger::log_search_context_switch ( std::size_t  dest_context_ID,
size_t  src_context_ID 
)
Here is the call graph for this function:

◆ log_show_detail_display()

void Logger::log_show_detail_display ( const DatasetFrames _dataset_frames,
FrameId  frame_ID 
)
Here is the call graph for this function:

◆ log_show_random_display()

void Logger::log_show_random_display ( const DatasetFrames _dataset_frames,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_som_display()

void Logger::log_show_som_display ( const DatasetFrames _dataset_frames,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_som_relocation_display()

void Logger::log_show_som_relocation_display ( const DatasetFrames _dataset_frames,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_topknn_display()

void Logger::log_show_topknn_display ( const DatasetFrames _dataset_frames,
FrameId  frame_ID,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_topn_context_display()

void Logger::log_show_topn_context_display ( const DatasetFrames _dataset_frames,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_topn_display()

void Logger::log_show_topn_display ( const DatasetFrames _dataset_frames,
const std::vector< FrameId > &  imgs 
)
Here is the call graph for this function:

◆ log_show_video_replay()

void Logger::log_show_video_replay ( const DatasetFrames _dataset_frames,
FrameId  frame_ID,
float  delta 
)
Here is the call graph for this function:

◆ log_submit()

void Logger::log_submit ( const VideoFrame  frame,
bool  submit_result 
)

Called whenever we want to log submit frame/shot into the server.

Here is the call graph for this function:

◆ log_text_query_change()

void Logger::log_text_query_change ( const std::string &  query_sentence)
Here is the call graph for this function:

◆ log_unbookmark()

void Logger::log_unbookmark ( FrameId  frame_ID)
Here is the call graph for this function:

◆ log_unlike()

void Logger::log_unlike ( FrameId  frame_ID)
Here is the call graph for this function:

◆ poll()

void Logger::poll ( )

Does periodic cleanup & log flush.

Here is the call graph for this function:

◆ push_action()

LogHash Logger::push_action ( const std::string &  action_name,
const std::string &  cat,
const std::string &  type,
const std::string &  value,
nlohmann::json &&  our_log_JSON = {},
std::initializer_list< std::string >  summary_keys = {} 
)
private
Here is the call graph for this function:

◆ submit_interaction_logs_buffer()

void Logger::submit_interaction_logs_buffer ( )

Sends the accumulated logs to the evaluation server (through _p_eval_server).

Here is the call graph for this function:

◆ write_action()

void sh::Logger::write_action ( const nlohmann::json &  action_log)
inlineprivate

Writes the log into the local file.

◆ write_result()

void sh::Logger::write_result ( const nlohmann::json &  action_log)
inlineprivate

Writes the log into the local file.

◆ write_summary()

void sh::Logger::write_summary ( const nlohmann::json &  log,
const std::string &  action_name,
std::initializer_list< std::string >  keys = {} 
)
inlineprivate

Writes the log into the local file.

Member Data Documentation

◆ _actions_log_stream

std::ofstream sh::Logger::_actions_log_stream
private

◆ _actions_streams

std::vector<std::stringstream> sh::Logger::_actions_streams
private

◆ _first_actions

bool sh::Logger::_first_actions { true }
private

◆ _first_result

bool sh::Logger::_first_result { true }
private

◆ _interactions_buffer

std::vector<nlohmann::json> sh::Logger::_interactions_buffer
private

◆ _last_interactions_submit_ts

UnixTimestamp sh::Logger::_last_interactions_submit_ts
private

◆ _logger_settings

const EvalServerSettings sh::Logger::_logger_settings
private

◆ _p_eval_server

EvalServerClient* sh::Logger::_p_eval_server
private

◆ _p_user_ctx

const UserContext* sh::Logger::_p_user_ctx
private

◆ _push_action_mtx

std::mutex sh::Logger::_push_action_mtx
mutableprivate

◆ _results_log_stream

std::ofstream sh::Logger::_results_log_stream
private

◆ _results_streams

std::vector<std::stringstream> sh::Logger::_results_streams
private

◆ _summary_log_stream

std::ofstream sh::Logger::_summary_log_stream
private

◆ _summary_streams

std::vector<std::stringstream> sh::Logger::_summary_streams
private

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