@@ -57,6 +57,12 @@ class QueryEvents {
57
57
58
58
virtual void OnProgress (const Progress& progress) = 0;
59
59
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
+
60
66
virtual void OnFinish () = 0;
61
67
};
62
68
@@ -65,6 +71,7 @@ using ExceptionCallback = std::function<void(const Exception& e)>;
65
71
using ProgressCallback = std::function<void (const Progress& progress)>;
66
72
using SelectCallback = std::function<void (const Block& block)>;
67
73
using SelectCancelableCallback = std::function<bool (const Block& block)>;
74
+ using SelectServerLogCallback = std::function<bool (const Block& block)>;
68
75
69
76
70
77
class Query : public QueryEvents {
@@ -122,6 +129,12 @@ class Query : public QueryEvents {
122
129
return *this ;
123
130
}
124
131
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
+
125
138
static const std::string default_query_id;
126
139
127
140
private:
@@ -155,6 +168,12 @@ class Query : public QueryEvents {
155
168
}
156
169
}
157
170
171
+ void OnServerLog (const Block& block) override {
172
+ if (select_server_log_cb_) {
173
+ select_server_log_cb_ (block);
174
+ }
175
+ }
176
+
158
177
void OnFinish () override {
159
178
}
160
179
@@ -166,6 +185,7 @@ class Query : public QueryEvents {
166
185
ProgressCallback progress_cb_;
167
186
SelectCallback select_cb_;
168
187
SelectCancelableCallback select_cancelable_cb_;
188
+ SelectServerLogCallback select_server_log_cb_;
169
189
};
170
190
171
191
}
0 commit comments