Validate and record an event.

        >>> record('event.action', object_instance)
189813
def record(self,
               event_type: str,
               event_data: Mapping = None,
               instance: Any = None,
               **kwargs) -> 'Event':
        
        if not self.is_setup:
            return
        if not self.can_handle(event_type=event_type):
            return

        event = self.get_event(event_type=event_type,
                               event_data=event_data,
                               instance=instance,
                               **kwargs)
        self.record_event(event)
        return event
863149
function _validateKinesisStreamEventRecord(record) {
  if (!record.kinesis) {
    throw new Error(`Missing kinesis property for Kinesis stream event record (${record.eventID})`);
  }
  if (!record.kinesis.data) {
    throw new Error(`Missing data property for Kinesis stream event record (${record.eventID})`);
  }
  if (!record.kinesis.partitionKey) {
    throw new Error(`Missing partitionKey property for Kinesis stream event record (${record.eventID})`);
  }
  if (!record.kinesis.sequenceNumber) {
    throw new Error(`Missing sequenceNumber property for Kinesis stream event record (${record.eventID})`);
  }
}
210720
def event_happened(event_name, model)
      self.last_action = event_name
      self.last_updated_node = model
      self.updated_at = Time.zone.now
      self.save!
    end
58577
def register_event(cls, event_name, event, method):
        
        log.info('@Registry.register_event `{}` with subscriber `{}`'
                 .format(event_name, method.__name__))

        if event_name not in cls._events:
            cls._events[event_name] = {}

        if event not in cls._events[event_name]:
            cls._events[event_name][event] = []

        cls._events[event_name][event].append(method)
651520
def _trigger_event(self, event):
    

    if event is None or event not in self.__listeners:
      raise ValueError('invalid event type: {0!r}'.format(event))

    # Check the event has not already been triggered, then mark
    # the event as triggered.
    if event in self.__event_set:
      raise RuntimeError('event already triggered: {0!r}'.format(event))
    self.__event_set.add(event)
    listeners = self.__listeners[event] + self.__listeners[None]

    # Remove one-off listeners.
    self.__listeners[event][:] = (l for l in self.__listeners[event] if not l.once)
    self.__listeners[None][:] = (l for l in self.__listeners[None] if not l.once)

    for listener in listeners:
      # XXX: What to do on exceptions? Catch and make sure all listeners
      # run through? What to do with the exception(s) then?
      listener.callback(self, event)
355297
def emit(self, record):
        
        # Skip records less than min_level
        if record.levelno < logging.getLevelName(self.min_level):
            return

        evt = LogEvent()
        evt.level = record.levelname
        evt.levelno = record.levelno
        evt.timestamp = datetime.fromtimestamp(record.created)
        evt.message = record.message
        evt.filename = record.filename
        evt.lineno = record.lineno
        evt.module = record.module
        evt.funcname = record.funcName
        evt.pathname = record.pathname
        evt.process_id = record.process

        # Only log stacktraces if its the level is ERROR or higher
        if record.levelno >= 40:
            evt.stacktrace = traceback.format_exc()

        try:
            db.session.add(evt)
            db.session.commit()
        except Exception:
            db.session.rollback()
300756
def capture(self, event_type, date=None, context=None, custom=None, stack=None, handled=True, **kwargs):
        
        if event_type == "Exception":
            # never gather log stack for exceptions
            stack = False
        data = self._build_msg_for_logging(
            event_type, date=date, context=context, custom=custom, stack=stack, handled=handled, **kwargs
        )

        if data:
            # queue data, and flush the queue if this is an unhandled exception
            self.queue(ERROR, data, flush=not handled)
            return data["id"]
576686
def trigger_event(self, event, client, args, force_dispatch=False):
        """"""
        self.controller.process_event(event, client, args, force_dispatch=force_dispatch)
1152439
def on_event(event_handler = nil, &block)
      event_handler ||= block
      raise ArgumentError, "no event_handler provided" if event_handler.nil?
      @event_handler = event_handler
    end
1246940
def ObjectInitializedEventHandler(obj, event):
    

    # only snapshot supported objects
    if not supports_snapshots(obj):
        return

    # object has already snapshots
    if has_snapshots(obj):
        return

    # take a new snapshot
    take_snapshot(obj, action="create")
237184
function validateEvent(event) {
	if (typeof event !== 'object' || !event) throw new TypeError('event must be an Object');
	if (typeof event.type !== 'string' || !event.type.length) throw new TypeError('event.type must be a non-empty String');
	if (!event.aggregateId && !event.sagaId) throw new TypeError('either event.aggregateId or event.sagaId is required');
	if (event.sagaId && typeof event.sagaVersion === 'undefined') throw new TypeError('event.sagaVersion is required, when event.sagaId is defined');
}
288274
def record_event(self, event: Event) -> None:
        
        from polyaxon.celery_api import celery_app
        from polyaxon.settings import EventsCeleryTasks

        if not event.ref_id:
            event.ref_id = self.get_ref_id()
        serialized_event = event.serialize(dumps=False,
                                           include_actor_name=True,
                                           include_instance_info=True)

        celery_app.send_task(EventsCeleryTasks.EVENTS_TRACK, kwargs={'event': serialized_event})
        celery_app.send_task(EventsCeleryTasks.EVENTS_LOG, kwargs={'event': serialized_event})
        celery_app.send_task(EventsCeleryTasks.EVENTS_NOTIFY, kwargs={'event': serialized_event})
        # We include the instance in the serialized event for executor
        serialized_event['instance'] = event.instance
        self.executor.record(event_type=event.event_type, event_data=serialized_event)
830375
def action_log_create(sender, instance, created, **kwargs):
    
    if created:
        changes = model_instance_diff(None, instance)

        log_entry = LogAction.objects.create_log_action(
            instance=instance,
            action=LogAction.CREATE,
            changes=json.dumps(changes),
        )
462977
function validate() {

    logger.logEnter('validate');

    for (var i = 0; i < buffer.length; i++) {

      var eventData = buffer[i],
        typeName = eventData[0],
        typeKeys = eventTypes[typeName];

      if (!typeKeys) {

        emitter.emit('error', typeName + ' is not a known event type.');

        // Remove these events.
        eventCount -= eventData.length - 1;
        buffer.splice(i, 1);
        i--;

      } else {

        for (var j = 1; j < eventData.length; j++) {

          if (!validEvent(Object.keys(eventData[j]), typeKeys, emitter, typeName)) {

            // Remove this event.
            eventCount--;
            if (eventData.length === 2) {
              buffer.splice(i, 1);
              i--;
              break;
            } else {
              eventData.splice(j, 1);
              j--;
            }
          }
        }
      }
    }

    logger.logExit('validate');
  }
553738
function recordTiming (name, timing) {
  recorder[name] = parseInt(timing, 10) || Date.now()
  performanceEvent.trigger('update', getTiming())
}
400200
def record(method, *args, &block)
      self << {method: method, args: DeepDup.(args), block: block} # DISCUSS: options.dup.
    end
1238521
def parse_event_record(self, node):
        

        if self.current_simulation == None:
            self.raise_error('<EventRecord> must be only be used inside a ' +
                             'simulation specification')

        if 'quantity' in node.lattrib:
            quantity = node.lattrib['quantity']
        else:
            self.raise_error('<EventRecord> must specify a quantity.')

        if 'eventport' in node.lattrib:
            eventPort = node.lattrib['eventport']
        else:
            self.raise_error('<EventRecord> must specify an eventPort.')


        self.current_simulation.add_event_record(EventRecord(quantity, eventPort))