##// END OF EJS Templates
Better way of logging events
Jessica B. Hamrick -
Show More
@@ -90,6 +90,23 b' define(['
90 this.events.on('send_input_reply.Kernel', function(evt, data) {
90 this.events.on('send_input_reply.Kernel', function(evt, data) {
91 that.send_input_reply(data);
91 that.send_input_reply(data);
92 });
92 });
93
94 var record_status = function (evt) {
95 console.log('Kernel: ' + evt.type + ' (' + that.id + ')');
96 };
97
98 this.events.on('kernel_started.Kernel', record_status);
99 this.events.on('status_reconnecting.Kernel', record_status);
100 this.events.on('status_connected.Kernel', record_status);
101 this.events.on('status_starting.Kernel', record_status);
102 this.events.on('status_restarting.Kernel', record_status);
103 this.events.on('status_autorestarting.Kernel', record_status);
104 this.events.on('status_interrupting.Kernel', record_status);
105 this.events.on('status_disconnected.Kernel', record_status);
106 this.events.on('status_idle.Kernel', record_status);
107 this.events.on('status_busy.Kernel', record_status);
108 this.events.on('status_killed.Kernel', record_status);
109 this.events.on('kernel_dead.Kernel', record_status);
93 };
110 };
94
111
95 /**
112 /**
@@ -206,7 +223,6 b' define(['
206 * @param {function} [error] - functon executed on ajax error
223 * @param {function} [error] - functon executed on ajax error
207 */
224 */
208 Kernel.prototype.kill = function (success, error) {
225 Kernel.prototype.kill = function (success, error) {
209 console.log("Killing kernel: " + this.id);
210 this.events.trigger('status_killed.Kernel', {kernel: this});
226 this.events.trigger('status_killed.Kernel', {kernel: this});
211 this._kernel_dead();
227 this._kernel_dead();
212 $.ajax(this.kernel_url, {
228 $.ajax(this.kernel_url, {
@@ -229,13 +245,11 b' define(['
229 * @param {function} [error] - functon executed on ajax error
245 * @param {function} [error] - functon executed on ajax error
230 */
246 */
231 Kernel.prototype.interrupt = function (success, error) {
247 Kernel.prototype.interrupt = function (success, error) {
232 console.log("Interrupting kernel: " + this.id);
233 this.events.trigger('status_interrupting.Kernel', {kernel: this});
248 this.events.trigger('status_interrupting.Kernel', {kernel: this});
234 this.events.trigger('status_busy.Kernel', {kernel: this});
235
249
236 var that = this;
250 var that = this;
237 var on_success = function (data, status, xhr) {
251 var on_success = function (data, status, xhr) {
238 that.events.trigger('status_idle.Kernel', {kernel: this});
252 that.kernel_info(); // get kernel info so we know what state the kernel is in
239 if (success) {
253 if (success) {
240 success(data, status, xhr);
254 success(data, status, xhr);
241 }
255 }
@@ -262,7 +276,6 b' define(['
262 * @param {function} [error] - functon executed on ajax error
276 * @param {function} [error] - functon executed on ajax error
263 */
277 */
264 Kernel.prototype.restart = function (success, error) {
278 Kernel.prototype.restart = function (success, error) {
265 console.log("Restarting kernel: " + this.id);
266 this.events.trigger('status_restarting.Kernel', {kernel: this});
279 this.events.trigger('status_restarting.Kernel', {kernel: this});
267 this.stop_channels();
280 this.stop_channels();
268
281
@@ -302,9 +315,8 b' define(['
302 * @function reconnect
315 * @function reconnect
303 */
316 */
304 Kernel.prototype.reconnect = function () {
317 Kernel.prototype.reconnect = function () {
305 console.log("Reconnecting to kernel: " + this.id);
306 this.events.trigger('status_reconnecting.Kernel', {kernel: this});
318 this.events.trigger('status_reconnecting.Kernel', {kernel: this});
307 setTimeout($.proxy(this.start_channels, this), 3000)
319 setTimeout($.proxy(this.start_channels, this), 3000);
308 };
320 };
309
321
310 /**
322 /**
@@ -356,7 +368,6 b' define(['
356 this.id = data.id;
368 this.id = data.id;
357 this.kernel_url = utils.url_join_encode(this.kernel_service_url, this.id);
369 this.kernel_url = utils.url_join_encode(this.kernel_service_url, this.id);
358
370
359 console.log("Kernel started: ", this.id);
360 this.start_channels();
371 this.start_channels();
361 };
372 };
362
373
@@ -368,13 +379,8 b' define(['
368 * @function _kernel_connected
379 * @function _kernel_connected
369 */
380 */
370 Kernel.prototype._kernel_connected = function () {
381 Kernel.prototype._kernel_connected = function () {
371 console.log('Connected to kernel: ', this.id);
372 this.events.trigger('status_connected.Kernel', {kernel: this});
382 this.events.trigger('status_connected.Kernel', {kernel: this});
373
383 this.kernel_info(); // get kernel info so we know what state the kernel is in
374 var that = this;
375 this.kernel_info(function () {
376 that.events.trigger('status_idle.Kernel', {kernel: this});
377 });
378 };
384 };
379
385
380 /**
386 /**
@@ -385,7 +391,6 b' define(['
385 * @function _kernel_dead
391 * @function _kernel_dead
386 */
392 */
387 Kernel.prototype._kernel_dead = function () {
393 Kernel.prototype._kernel_dead = function () {
388 console.log('Dead kernel: ', this.id);
389 this.stop_channels();
394 this.stop_channels();
390 };
395 };
391
396
@@ -907,7 +912,6 b' define(['
907 // autorestart shows the more prominent dialog.
912 // autorestart shows the more prominent dialog.
908 this.events.trigger('status_restarting.Kernel', {kernel: this});
913 this.events.trigger('status_restarting.Kernel', {kernel: this});
909 this.events.trigger('status_autorestarting.Kernel', {kernel: this});
914 this.events.trigger('status_autorestarting.Kernel', {kernel: this});
910 console.log("Kernel is autorestarting: " + this.id);
911
915
912 } else if (execution_state === 'dead') {
916 } else if (execution_state === 'dead') {
913 this.events.trigger('kernel_dead.Kernel', {kernel: this});
917 this.events.trigger('kernel_dead.Kernel', {kernel: this});
@@ -44,8 +44,22 b' define(['
44 this.notebook = options.notebook;
44 this.notebook = options.notebook;
45 this.kernel = null;
45 this.kernel = null;
46 this.events = options.notebook.events;
46 this.events = options.notebook.events;
47
48 this.bind_events();
47 };
49 };
48
50
51 Session.prototype.bind_events = function () {
52 var that = this;
53 var record_status = function (evt) {
54 console.log('Session: ' + evt.type + ' (' + that.id + ')');
55 };
56
57 this.events.on('kernel_started.Session', record_status);
58 this.events.on('kernel_dead.Session', record_status);
59 this.events.on('status_killed.Session', record_status);
60 };
61
62
49 // Public REST api functions
63 // Public REST api functions
50
64
51 /**
65 /**
General Comments 0
You need to be logged in to leave comments. Login now