Jump to content

LogOpenFile

From EDM2
Revision as of 21:18, 21 January 2018 by Martini (talk | contribs) (Created page with " LogOpenFile opens a log file so that it can be read using LogReadEntry. LogOpenFile returns a log_file_ID number that is used to refer to the file. For Error Logging: Speci...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
LogOpenFile opens a log file so that it can be read using LogReadEntry. LogOpenFile returns a log_file_ID number that is used to refer to the file.

For Error Logging:

Specify either a log_file_ID number or a path name. If the log_file_ID number is specified and the log_file_ID is valid the path name is returned. If a path name is specified, the Logging Service will return the log_file_ID that corresponds to the file. (The file will be opened if it is not already open.)

Syntax

LogOpenFile(service, pOpenFile);

Parameters

service (ULONG) - input
The class of Logging Service:
  • Error logging
  • All other values are reserved for future use.
pOpenFile (PVOID) - in/out
A pointer to the LogOpenFile parameter packet.
For Error Logging, this is a pointer to a LOFREQUEST structure.

Returns

rc (APIRET) - returns
Return code.
LogOpenFile returns the following values:
  • 0 No error
  • 2 Error file not found
  • 99 Error device in use
  • 108 Error drive locked
  • 110 Error open failed
  • 523 Error LF invalid service
  • 524 Error LF general failure
  • 1703 Invalid data pointer
  • 1701 Invalid LF log file id
  • 1702 Invalid LF packet revision number
  • 1704 Invalid LF filename length
  • 1705 Invalid LF filename ptr
  • 1706 Invalid LF parm packet ptr
  • 1732 Invalid LF log file
  • 1761 Error LF invalid packet size

Remarks

The library LFAPI.LIB must be linked with object files that use LogOpenFile

Example Code

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

ULONG     service;
PVOID     pOpenFile;
APIRET    rc;

rc = LogOpenFile(service, pOpenFile);

The following example verifies that the default file (1) is opened.

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

  {
  APIRET rc;                      /* return code */
  ULONG service;
  UniChar filename›256!;
  ULONG filename_length;
  ULONG log_file_ID;
  LOFREQUEST open_file_packet;

  service = ERROR_LOGGING_SERVICE;

  /* Construct the LogOpenFile parameter packet  */
  open_file_packet.packet_size = sizeof(LOFREQUEST);
  open_file_packet.packet_revision_number = LF_UNI_API;
  log_file_ID = ERROR_LOG_FILE_ID;
  open_file_packet.log_file_ID = &log_file_ID;
  open_file_packet.filename_length = &filename_length; /*Indicates use the
                                                               Log File ID   */
  open_file_packet.filename = &filename;

  rc = LogOpenFile(service,                       /* service */
              &open_file_packet)              /* parameter packet  */

  if (rc |= 0)
    {
     printf("LogOpenFile error: return code = %d",rc);
     return;
    }

Related