AddLog Example
AddLog Example
The example in this section demonstrates how to implement
SAF for logging only three items of information about a request: the IP address, the
method, and the URI (for example,
/jocelyn/dogs/homesneeded.html
Installing the Example
To load the shared object containing your functions add the following line in the
Init
Init fn=load-modules shlib=
To call
magnus.conf
brief-init
Init fn=brief-init file=/tmp/brief.log
To execute your custom SAF during the
following line to that object in the
AddLog fn=brief-log
Source Code
The source code is in
plugins/nsapi/examples
#include "nsapi.h"
#include "base/daemon.h" /* daemon_atrestart */
#include "base/file.h"
#include "base/util.h"
/* File descriptor to be shared between the processes */
static SYS_FILE logfd = SYS_ERROR_FD;
#ifdef __cplusplus
extern "C"
#endif
228
Netscape Enterprise Server NSAPI Programmer's Guide • November 2001
section of the
magnus.conf
to open the log file, add the following line to the
brief-init
. (This line must come after the one that loads the library containing
).
addlog.c
198.93.95.99 GET
).
file:
yourlibrary
funcs=brief-init,brief-log
AddLog
file:
obj.conf
is in the
nsapi/examples/
subdirectory within the server root directory.
/* system_fopenWA, system_fclose */
/* sprintf */
brief-log
Init
stage for some object, add the
or
, a custom
section in