Example #1
0
void EventDump(mps_lib_FILE *stream)
{
  Event event;
  EventKind kind;

  AVER(stream != NULL);

  /* This can happen if there's a backtrace very early in the life of
     the MPS, and will cause an access violation if we continue. */
  if (!eventInited) {
    (void)WriteF(stream, 0, "No events\n", NULL);
    return;
  }

  for (kind = 0; kind < EventKindLIMIT; ++kind) {
    for (event = (Event)EventLast[kind];
         (char *)event < EventBuffer[kind] + EventBufferSIZE;
         event = (Event)((char *)event + event->any.size)) {
      /* Try to keep going even if there's an error, because this is used as a
         backtrace and we'll take what we can get. */
      (void)EventWrite(event, stream);
      (void)WriteF(stream, 0, "\n", NULL);
    }
  }
}
Example #2
0
Status WindowsEventLoggerPlugin::emitLogRecord(
    REGHANDLE registration_handle,
    const std::string& message,
    StatusLogSeverity severity,
    const std::string& source_file_name,
    size_t line) {
  if (registration_handle == 0) {
    return Status(1, "The Windows Event Logger plugin is not initialized.");
  }

  EVENT_DATA_DESCRIPTOR data_descriptor[2] = {};
  EventDataDescCreate(&data_descriptor[0],
                      message.data(),
                      static_cast<ULONG>(message.size() + 1));

  auto location = source_file_name + ":" + std::to_string(line);
  EventDataDescCreate(&data_descriptor[1],
                      location.data(),
                      static_cast<ULONG>(location.size() + 1));

  const EVENT_DESCRIPTOR* event_descriptor = nullptr;
  switch (severity) {
  case O_WARNING: {
    event_descriptor = &WarningMessage;
    break;
  }

  case O_ERROR: {
    event_descriptor = &ErrorMessage;
    break;
  }

  case O_FATAL: {
    event_descriptor = &FatalMessage;
    break;
  }

  case O_INFO:
  default: {
    event_descriptor = &InfoMessage;
    break;
  }
  }

  auto status =
      EventWrite(registration_handle, event_descriptor, 2, data_descriptor);
  if (status != ERROR_SUCCESS) {
    auto error_message =
        std::string("Failed to publish the following log record: ") + location +
        " " + message;
    return Status(1, std::move(error_message));
  }

  return Status();
}
Example #3
0
void ETWLogger::err(const std::string& msg) {
	EVENT_DATA_DESCRIPTOR descr;
	EventDataDescCreate(&descr, msg.c_str(), static_cast<ULONG>(msg.size()));
	auto status = EventWrite(
		m_registration_handle,
		&ErrEvent,
		1,
		&descr
		);
	if (status != 0) DebugBreak();
}
Example #4
0
    virtual void Write(int level, int opcode, char * msg, va_list argptr)
    {
        //event not registered
        if (0==m_EventHandle)
        {
            return;
        }
        if (!m_bProviderEnable)
        {
            return;
        }
        if (level == DL_LOADED_LIBRARY)
        {
            return;
        }

        char msg_formated[1024];
        EVENT_DESCRIPTOR descriptor;
        EVENT_DATA_DESCRIPTOR data_descriptor;

        EventDescZero(&descriptor);
        
        descriptor.Opcode = (UCHAR)opcode; 
        descriptor.Level  = (UCHAR)level;
        
        if (m_bUseFormatter)
        {
            if (NULL != msg)
            {
#if _MSC_VER >= 1400
                vsprintf_s(msg_formated, sizeof (msg_formated) / sizeof (msg_formated[0]), msg, argptr);
#else
                vsnprintf(msg_formated, sizeof (msg_formated) / sizeof (msg_formated[0]), msg, argptr);
#endif
                EventDataDescCreate(&data_descriptor, msg_formated, (ULONG)(strlen(msg_formated) + 1));
            }else
            {
                EventDataDescCreate(&data_descriptor, NULL, 0);
            }
        }else
        {
            //TODO: non formated events supports under zbb 
        }

        EventWrite(m_EventHandle, &descriptor, 1, &data_descriptor);
    }
Example #5
0
void EventDump(mps_lib_FILE *stream)
{
  Event event;
  EventKind kind;

  AVER(stream != NULL);

  for (kind = 0; kind < EventKindLIMIT; ++kind) {
    for (event = (Event)EventLast[kind];
         event < (Event)(EventBuffer[kind] + EventBufferSIZE);
         event = (Event)((char *)event + event->any.size)) {
      /* Try to keep going even if there's an error, because this is used as a
         backtrace and we'll take what we can get. */
      (void)EventWrite(event, stream);
      (void)WriteF(stream, "\n", NULL);
    }
  }
}
Example #6
0
uint32_t PalEventWrite(REGHANDLE arg1, const EVENT_DESCRIPTOR * arg2, uint32_t arg3, EVENT_DATA_DESCRIPTOR * arg4)
{
    return EventWrite(arg1, arg2, arg3, arg4);
}
void serverQtComponent::EventWriteQSlot(int newValue)
{
    mtsInt payload;
    payload.Data = newValue;
    EventWrite(payload);
}