Provides utility methods for use in EAServer ActiveX components.
WriteLog – Writes a message to the server’s log file.
To create an IJagServer interface pointer, use the ProgID, “Jaguar.JagServer.1”. Call the OLE routines CLSIDfromProgID and CoCreateInstance. CoCreateInstance returns an interface pointer for a given ActiveX class ID string. CLSIDfromProgID obtains the class ID string that CoCreateInstance requires.
To use the IJagServer and IJagServerResults interfaces, you must include JagAxWrap.h. Additionally, you must include JagAxWrap_i.c in only one source file for your component DLL. JagAxWrap.h contains interface definitions for the documented interfaces. JagAxWrap_i.c declares symbols that are required by the ActiveX CoCreateInstance routine.
WARNING! You will get duplicate-symbol link errors if you include JagAxWrap_i.c in more than one source file for your component DLL.
Chapter 19, “Creating ActiveX Components,” in the EAServer Programmer’s Guide
Writes a message to the server’s log file.
#include <JagAxWrap.h> HRESULT IJagServer::WriteLog( VARIANT_BOOL useTimeStamp, BSTR message)
VARIANT_TRUE
if
the current date and time should be prepended to the log message; VARIANT_FALSE
otherwise.
A message to be written to the server’s log file.
Return value |
To indicate |
---|---|
S_OK |
Successful execution. |
E_OUTOFMEMORY |
Out of memory. |
E_FAIL |
Failure. WriteLog fails if the log file cannot be opened or if message is NULL. If the log file cannot be opened, log messages are written to the server process’ standard error device. |
This method records a message in the server’s log file.
By convention, errors that occur on the server are recorded in the log. Log messages should contain enough detail for an administrator or programmer to troubleshoot the cause of the error.
After recording error information in the log, you can also send a concise description of the error by raising an OLE automation exception.
For information on configuring the log file used by the server, see Chapter 3, “Creating and Configuring Servers,” in the EAServer System Administration Guide.
When coding in C++, you can call the C routine JagLog instead of IJagServer::WriteLog. Calling the C routine avoids the overhead incurred by creating an IJagServer interface pointer.
The following C++ code fragment creates an IJagServer interface pointer and calls WriteLog to log the message “Hello, logfile”:
HRESULT hr; IJagServer *p_ijs; CLSID clsid_js; BSTR msg; // Create an IJagServer interface pointer hr = CLSIDFromProgID(L"Jaguar.JagServer.1", &clsid_js); // ... deleted error checking ...
hr = CoCreateInstance(clsid_js, NULL, CLSCTX_INPROC_SERVER, IID_IJagServer, (void**)&p_ijs); // ... deleted error checking ...
msg = SysAllocString(L"Hello, logfile\n"); // ... deleted error checking ...
hr = p_ijs->WriteLog(VARIANT_TRUE, msg); // ... deleted error checking ...
Chapter 19, “Creating ActiveX Components,” in the EAServer Programmer’s Guide
JagLog in Chapter 5, “C Routines Reference.”
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |