'Captures, processes and serializes an event into a dict object
The result of ``build_msg`` should be a standardized dict, with
all default values available.'

def build_msg(self, event_type, data=None, date=None, time_spent=None, extra=None, stack=None, public_key=None, tags=None, fingerprint=None, **kwargs):

    event_id = uuid.uuid4().hex
    data = merge_dicts(self.context.data, data)
    data.setdefault('tags', {})
    data.setdefault('extra', {})
    if ('.' not in event_type):
        event_type = ('raven.events.%s' % event_type)
    handler = self.get_handler(event_type)
    result = handler.capture(**kwargs)
    culprit = result.pop('culprit', None)
    if data.get('culprit'):
        culprit = data['culprit']
    for (k, v) in iteritems(result):
        if (k not in data):
            data[k] = v
    if ((stack is None) and ('exception' not in data)):
        stack = self.auto_log_stacks
    if (stack and ('stacktrace' not in data)):
        if (stack is True):
            frames = iter_stack_frames()
        else:
            frames = stack
        stack_info = get_stack_info(frames, transformer=self.transform, capture_locals=self.capture_locals)
        data.update({'stacktrace': stack_info})
    if self.include_paths:
        for frame in self._iter_frames(data):
            if (frame.get('in_app') is not None):
                continue
            path = frame.get('module')
            if (not path):
                continue
            if path.startswith('raven.'):
                frame['in_app'] = False
            else:
                frame['in_app'] = (any((path.startswith(x) for x in self.include_paths)) and (not any((path.startswith(x) for x in self.exclude_paths))))
    if (not culprit):
        culprit = self.transaction.peek()
    if (not data.get('level')):
        data['level'] = (kwargs.get('level') or logging.ERROR)
    if (not data.get('server_name')):
        data['server_name'] = self.name
    if (not data.get('modules')):
        data['modules'] = self.get_module_versions()
    if (self.release is not None):
        data['release'] = self.release
    if (self.environment is not None):
        data['environment'] = self.environment
    data['tags'] = merge_dicts(self.tags, data['tags'], tags)
    data['extra'] = merge_dicts(self.extra, data['extra'], extra)
    site = (data.pop('site', None) or self.site)
    if site:
        data['tags'].setdefault('site', site)
    if culprit:
        data['culprit'] = culprit
    if fingerprint:
        data['fingerprint'] = fingerprint
    for processor in self.get_processors():
        data.update(processor.process(data))
    if ('message' not in data):
        data['message'] = kwargs.get('message', handler.to_string(data))
    for (key, value) in iteritems(data['tags']):
        data['tags'][key] = to_unicode(value)
    for (k, v) in iteritems(data['extra']):
        data['extra'][k] = self.transform(v)
    data.setdefault('project', self.remote.project)
    data.setdefault('timestamp', (date or datetime.utcnow()))
    data.setdefault('time_spent', time_spent)
    data.setdefault('event_id', event_id)
    data.setdefault('platform', PLATFORM_NAME)
    data.setdefault('sdk', SDK_VALUE)
    data.setdefault('repos', self.repos)
    if self.enable_breadcrumbs:
        crumbs = self.context.breadcrumbs.get_buffer()
        if crumbs:
            data.setdefault('breadcrumbs', {'values': crumbs})
    return data
