"""Django DDP logging helpers."""
from __future__ import absolute_import, print_function

import logging

from dddp import THREAD_LOCAL as this, meteor_random_id, ADDED


class DDPHandler(logging.Handler):

    """Logging handler that streams log events via DDP to the current client."""

    def emit(self, record):
        """Emit a formatted log record via DDP."""
        if getattr(this, 'subs', {}).get('Logs', False):
            this.send({
                'msg': ADDED,
                'collection': 'logs',
                'id': meteor_random_id('/collection/logs'),
                'fields': {
                    'name': record.name,
                    'levelno': record.levelno,
                    'levelname': record.levelname,
                    # 'pathname': record.pathname,
                    # 'lineno': record.lineno,
                    'msg': record.msg,
                    'args': record.args,
                    # 'exc_info': record.exc_info,
                    # 'funcName': record.funcName,
                },
            })

@@ -83,16 +83,32 @@
 nction%0A%0A
+import datetime%0A
 import l
@@ -614,16 +614,96 @@
 lds': %7B%0A
+                    'created': datetime.datetime.fromtimestamp(record.created),%0A
         

Fix bug in serialization of logging.LogRecord to show formatted message.