@@ -57,6 +57,12 @@ class QueryEvents {
5757
5858 virtual void OnProgress (const Progress& progress) = 0;
5959
60+ /* * Handle query execution logs provided by server.
61+ * Amount of logs regulated by `send_logs_level` setting.
62+ * By-default only `fatal` log events are sent to the client side.
63+ */
64+ virtual void OnServerLog (const Block& block) = 0;
65+
6066 virtual void OnFinish () = 0;
6167};
6268
@@ -65,6 +71,7 @@ using ExceptionCallback = std::function<void(const Exception& e)>;
6571using ProgressCallback = std::function<void (const Progress& progress)>;
6672using SelectCallback = std::function<void (const Block& block)>;
6773using SelectCancelableCallback = std::function<bool (const Block& block)>;
74+ using SelectServerLogCallback = std::function<bool (const Block& block)>;
6875
6976
7077class Query : public QueryEvents {
@@ -122,6 +129,12 @@ class Query : public QueryEvents {
122129 return *this ;
123130 }
124131
132+ // / Set handler for receiving a server log of query exceution.
133+ inline Query& OnServerLog (SelectServerLogCallback cb) {
134+ select_server_log_cb_ = std::move (cb);
135+ return *this ;
136+ }
137+
125138 static const std::string default_query_id;
126139
127140private:
@@ -155,6 +168,12 @@ class Query : public QueryEvents {
155168 }
156169 }
157170
171+ void OnServerLog (const Block& block) override {
172+ if (select_server_log_cb_) {
173+ select_server_log_cb_ (block);
174+ }
175+ }
176+
158177 void OnFinish () override {
159178 }
160179
@@ -166,6 +185,7 @@ class Query : public QueryEvents {
166185 ProgressCallback progress_cb_;
167186 SelectCallback select_cb_;
168187 SelectCancelableCallback select_cancelable_cb_;
188+ SelectServerLogCallback select_server_log_cb_;
169189};
170190
171191}
0 commit comments