32 #include <nlohmann/json.hpp>
41 using namespace json11;
64 void log_search_context_switch(std::
size_t dest_context_ID,
size_t src_context_ID);
67 void log_submit(const
VideoFrame frame,
bool submit_result);
70 void log_query(const
LogHash& hash, const
Query& query) const;
71 void log_canvas_query(const std::vector<
TemporalQuery>& temp_queries, const std::vector<
VideoFrame>* p_targets);
73 void log_rescore(const
Query& prev_query, const
Query& new_query);
78 const std::
string& sentence_query, const
size_t topn_frames_per_video,
79 const
size_t topn_frames_per_shot, const std::vector<
bool>& dataset_parts_filter = {
true,
true });
81 void log_text_query_change(
const std::string& query_sentence);
82 void log_canvas_query_change();
84 void log_like(
FrameId frame_ID);
85 void log_unlike(
FrameId frame_ID);
87 void log_bookmark(
FrameId frame_ID);
88 void log_unbookmark(
FrameId frame_ID);
90 void log_show_som_display(
const DatasetFrames& _dataset_frames,
const std::vector<FrameId>& imgs);
92 void log_show_som_relocation_display(
const DatasetFrames& _dataset_frames,
const std::vector<FrameId>& imgs);
94 void log_show_random_display(
const DatasetFrames& _dataset_frames,
const std::vector<FrameId>& imgs);
96 void log_show_topn_display(
const DatasetFrames& _dataset_frames,
const std::vector<FrameId>& imgs);
98 void log_show_topn_context_display(
const DatasetFrames& _dataset_frames,
const std::vector<FrameId>& imgs);
101 const std::vector<FrameId>& imgs);
105 void log_show_video_replay(
const DatasetFrames& _dataset_frames,
FrameId frame_ID,
float delta);
109 void log_reset_search();
112 void submit_interaction_logs_buffer();
116 _actions_streams.emplace_back(std::stringstream{}),
117 _results_streams.emplace_back(std::stringstream{}) };
121 _summary_streams.clear();
122 _actions_streams.clear();
123 _results_streams.clear();
127 void log_bothlike(
FrameId frame_ID,
const std::string& type);
130 LogHash push_action(
const std::string& action_name,
const std::string& cat,
const std::string& type,
131 const std::string& value, nlohmann::json&& our_log_JSON = {},
132 std::initializer_list<std::string> summary_keys = {});
136 std::stringstream ss;
140 _first_result =
false;
142 ss <<
"," << std::endl;
144 ss << action_log.dump(4);
146 _results_log_stream << ss.str();
147 for (
auto&& s : _results_streams) {
154 std::stringstream ss;
157 if (_first_actions) {
158 _first_actions =
false;
160 ss <<
"," << std::endl;
163 ss << action_log.dump(4);
165 _actions_log_stream << ss.str();
166 for (
auto&& s : _actions_streams) {
172 void write_summary(
const nlohmann::json& log,
const std::string& action_name,
173 std::initializer_list<std::string> keys = {}) {
174 auto ts{ log[
"metadata"][
"timestamp"].get<
UnixTimestamp>() };
175 auto hash{ log[
"metadata"][
"hash"].get<std::string>() };
177 std::stringstream ss;
181 for (
auto& [key, value] : log.items()) {
182 if (std::find(keys.begin(), keys.end(), key) == keys.end()) {
185 ss << key <<
"=" << value <<
"\t";
190 _summary_log_stream << ss.str();
192 for (
auto&& s : _summary_streams) {
196 std::string get_log_dir_queries()
const;
197 std::string get_results_log_filepath()
const;
198 std::string get_actions_log_filepath()
const;
199 std::string get_summary_log_filepath()
const;
220 bool _first_result{
true };
221 bool _first_actions{
true };
Definition: dataset-frames.h:162
Definition: eval-server-client.h:37
Definition: keyword-ranker.h:52
Class responsible for all the logging for the given user (each user have it's own Logger....
Definition: logger.h:53
void write_result(const nlohmann::json &action_log)
Writes the log into the local file.
Definition: logger.h:135
std::ofstream _results_log_stream
Definition: logger.h:212
DebugLogStreamPtrs get_debug_streams()
Definition: logger.h:114
std::vector< nlohmann::json > _interactions_buffer
Definition: logger.h:209
std::mutex _push_action_mtx
Definition: logger.h:223
void write_action(const nlohmann::json &action_log)
Writes the log into the local file.
Definition: logger.h:153
std::vector< std::stringstream > _summary_streams
Definition: logger.h:216
void clear_debug_streams()
Definition: logger.h:120
std::ofstream _summary_log_stream
Definition: logger.h:213
std::vector< std::stringstream > _actions_streams
Definition: logger.h:217
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.
Definition: logger.h:172
const EvalServerSettings _logger_settings
Definition: logger.h:201
const UserContext * _p_user_ctx
Definition: logger.h:206
EvalServerClient * _p_eval_server
Definition: logger.h:207
std::lock_guard< std::mutex > get_exclusive_actions_lock() const
Definition: logger.h:201
std::ofstream _actions_log_stream
Definition: logger.h:214
std::vector< std::stringstream > _results_streams
Definition: logger.h:218
UnixTimestamp _last_interactions_submit_ts
Definition: logger.h:210
Represents exactly one state of ONE user that uses this core.
Definition: user-context.h:38
std::string get_formated_timestamp(const std::string &fmt, UnixTimestamp ts=timestamp())
Returns string representing current time and date in formated string based on provided format.
Definition: utils.hpp:105
Definition: common-types.h:33
std::string LogHash
Definition: common-types.h:59
DisplayType
Definition: common-types.h:102
std::int64_t UnixTimestamp
Definition: common-types.h:54
unsigned long FrameId
Definition: common-types.h:75
Definition: common-types.h:44
Definition: settings.h:59
The type representing the whole query.
Definition: query-types.h:470
Definition: query-types.h:404
Definition: dataset-frames.h:40