1. Adrian Dries
  2. fenton

Commits

Adrian Dries  committed c7be38c

some client logging

  • Participants
  • Parent commits 7d0f259
  • Branches default

Comments (0)

Files changed (4)

File fenton/data.py

View file
  • Ignore whitespace
                 if event.comment:
                     event.action = 'COMMENT'
                 elif event.action != 'DELETE':
-                    print 'skipping non-event'
                     continue
             self.store_event(event, ts)
 

File fenton/static/fenton/js/fenton-core.js

View file
  • Ignore whitespace
     },
 
 
-    _disable_all: function () {
-        $('<div></div>')
-            .css({
-                zIndex: 99998,
-                position: 'absolute',
-                top: 0,
-                left: 0,
-                right: 0,
-                bottom: 0,
-                'background-color': '#666',
-                opacity: '0.7'
-            })
+    _disable_all: function (visual) {
+        Fenton._requests_disabled = true;
+        $('a[href]').removeAttr('href');
+        $('button, input').attr('disabled', 'disabled');
+        var style = {
+            zIndex: 99998,
+            position: 'absolute',
+            top: 0,
+            left: 0,
+            right: 0,
+            bottom: 0,
+            opacity: 0 // '0.1'
+        },
+        $d = $('<div></div>')
+            .css(style)
             .click(function () {return false})
             .appendTo(document.body);
+
+        if (visual) {
+            $('a, button').css('color', '#333');
+            $d.css('background-color', '#d4d4d4');
+            $d.fadeTo(10000, '0.9');
+        }
     },
 
 
         Fenton._request = null;
         Fenton._retry_count = 0;
         Fenton.show_error(Fenton.config.error_message + ' ' + msg);
+        Fenton._log_remote(msg);
     },
 
-
     _on_remote_success: function (data, status, rq) {
 
         if (rq.status == 0)
     },
 
 
+    _log_remote: function (msg) {
+        $.ajax({
+            dataType: 'json',
+            traditional: true,
+            dataFilter: null,
+            error: null,
+            complete: null,
+            success: null,
+            data: $.param([
+                {name: Fenton.config.xmlhttp_key, value: 1},
+                {name: Fenton.config.bind_key, value: Fenton.config.logger_bind},
+                {name: 'msg', value: msg}
+            ]),
+            context: {target: this}
+        });
+    },
+
+
     getSelectionStart: function(el) {
         if (!el.createTextRange)
             return el.selectionStart;
     },
 
     activate_remote: function (id, data) {
+        if (Fenton._requests_disabled)
+            return;
         if (data) {
             var encoded = [];
             for (var k in data)
         var ticker = $('<span>60 s</span>');
         Fenton.show_error($('<span>' + msg + '; refreshing in </span>')
                          .append(ticker));
+        Fenton._log_remote(msg);
         (function (i) {
             i = parseInt(ticker.text());
             if (i <= 1)

File fenton/view.py

View file
  • Ignore whitespace
 from fenton import util
 from fenton import getmeta
 from fenton import widgets
+from fenton import logging
 
 
 
             func = MethodWrapper(func)
         return self._bind(func, *args, **kw)
 
+    def bind_logger(self):
+        return self.bind(self.logmsg)
+
+    def logmsg(self):
+        msg = self.request.params.get('msg')
+        logging.log.info('[JS] %s', msg)
+
     def bind_heartbeat(self):
         if self.heartbeat:
             return self.bind(self.heartbeat_ping)
         es = dict((k, v and str(v)) for (k,v) in f.errors.items())
         self.vars['form_errors'] = es
         self.vars['form_error_msg'] = self.form_error_msg
+        for (k, v) in es.items():
+            if v is not None:
+                logging.log.debug('[form.error] %s: %s', k, v)
 
         pushback = f.get_pushback()
         if pushback:

File fenton/widgets.py

View file
  • Ignore whitespace
 
     def install_script(self):
         vars = {
+            'logger_bind': self.screen.bind_logger(),
             'error_message': self.app.default_error_message,
             'xmlhttp_key': self.request.xmlhttp_key,
             'model_key': self.request.model_key,