LogFormatEntry - Example Code

The following example formats an Error Log record for display. The calling program has placed the address of the locale object in locale.

  #define INCL_LOGGING
  #include <unidef.h>
  #include <os2.h>
  #include <stdio.h>
  #include <lfdef.h>

  {
  APIRET rc;                              /* return code */
  ULONG service;
  LFEREQUEST format_entry_packet;
  BYTE log_entry_buffer[1024];
  UniChar string_buffer[4096];
  #define STRING_BUFFER_LENGTH 4096
  ULONG string_buffer_length;
  LocaleObject locale;

  service = ERROR_LOGGING_SERVICE;
  string_buffer_length = STRING_BUFFER_LENGTH;
  rc = UniCreateLocaleObject(UNLUCS_STRING_POINTNER,(UniChar *) L"",&locale);
  if (rc |= 0)
    {
     printf("UniCreateLocaleObject error: return code = %d",rc);
     return;
    }

  /* Construct the Error Log Service format packet  */
  format_entry.packet.packet_size = sizeof(LFEREQUEST);
  format_entry_packet.packet_revision_number = WPOS_RELEASE_1;
  format_entry_packet.log_entry_buffer =  &log_entry_buffer;
  format_entry_packet.flags = ERR_FORMAT_DETAIL_DATA;
  format_entry_packet.locale_object = locale;
  format_entry_packet.string_buffer_length = &string_buffer_length;
  format_entry_packet.string_buffer =  &string_buffer;
  rc = LogFormatEntry(service,            /* service */
              &format_entry_packet)   /* parameter packet */
  if (rc |= 0)
    {
     printf("LogFormatEntry error: return code = %d",rc);
     return;
    }


[Back: LogFormatEntry - Related Functions]
[Next: LogFormatEntry - Topics]