The following example reads an entry from the default Error Logging log file. It searches for the first (that is, most recent) entry in the file that has a product manufacturer named "IBM" and a severity less than 4.

  #define INCL_LOGGING
  #include <unichar.h>
  #include <os2.h>
  #include <stdio.h>
  #define ERROR_LOG_FILE_ID	1
  #define START_AT_FIRST_ENTRY 0	.
          .
{
  ULONG service;
  ULONG severity = 4;
  ULONG entry_id = 12;
  LREREQUEST read_entry_packet;
  EVENTKEY EventKey;
  BYTE log_entry_buffer[2048];
  ULONG log_entry_buffer_length;
  SUBBLOCK subblock1, subblock2, subblock3;
  HEADERBLOCK headerblock1, headerblock2;
  FILTERBLOCK filter;

  struct UniCode_manufacturer_name {
         UniChar manufacturer_name[4] = L"IBM";
  } manufacturer_name;

  service = ERROR_LOGGING_SERVICE;

  /*  Construct an event notification filter with 2 header blocks.    */
  /*  The first header block points to a single subblock.      */
  /*  The second header block points to a chain of two subblocks.  */

  filter.packet_size = sizeof(FILTERBLOCK);
  filter.packet_revision_number = WPOS_RELEASE_1;
  filter.header_block = &headerblock1;
  filter.header_blocks = 2;

  /*-------------construct headerblock1---------------------*/
  headerblock1.pSubblock = &subblock1;
  headerblock1.subblocks_in_block = 1;
  headerblock1.pNextBlock = &headerblock2;

  /*construct subblock1 of headerblock1*/
  subblock1.entry_attribute_ID = LOG_ERROR_DMI_VENDOR_TAG;
  subblock1.comparison_operator = LOG_ERROR_EQUAL;
  subblock1.comparison_data_ptr = &manufacturer_name;
  subblock1.next_subblock = NULL;

  /*------------construct headerblock2----------------------*/
  headerblock1.pSubblock = &subblock2;
  headerblock1.subblocks_in_block = 2;
  headerblock1.pNextBlock = NULL;

  /*construct subblock2 of headerblock2*/
  subblock1.entry_attribute_ID = LOG_ERROR_SEVERITY;
  subblock1.comparison_operator = LOG_ERROR_LESS_THAN;
  subblock1.comparison_data_ptr = severity;
  subblock1.next_subblock = &subblock3;

  /*construct subblock3 of headerblock2*/
  subblock1.entry_attribute_ID = LOG_ERROR_ENTRY_ID;
  subblock1.comparison_operator = LOG_ERROR_GREATER_THAN;
  subblock1.comparison_data_ptr = entry_id;
  subblock1.next_subblock = null;

  /* Construct the LogReadEntry parameter packet. */
  read_entry_packet.packet_size = sizeof(LREREQUEST);
  read_entry_packet.packet_revision_number = WPOS_RELEASE_1;
  read_entry_packet.log_file_ID = ERROR_LOG_FILE_ID;
  read_entry_packet.flags = START_AT_FIRST_ENTRY;
  read_entry_packet.pEventKey = &EventKey;
  read_entry_packet.pFilter = &filter;
  log_entry_buffer_length = sizeof(log_entry_buffer);
  read_entry_packet.pLogEntryBufferLength = &log_entry_buffer_length;
  read_entry_packet.LogEntryBuffer = &log_entry_buffer;

  rc = LogReadEntry(service,           /*service*/
              &read_entry_packet); /*parameter packet*/

  if (rc != 0)
     {
     printf("LogReadEntry error: return code = %d",rc);
     return;


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