log.c File Reference

#include "nsd.h"

Data Structures

struct  LogCache

Defines

#define LOG_ROLL   1
#define LOG_EXPAND   2
#define LOG_DEBUG   4
#define LOG_DEV   8
#define LOG_NONOTICE   16
#define LOG_USEC   32

Functions

void NsInitLog (void)
void NsLogConf (void)
char * Ns_InfoErrorLog (void)
int Ns_LogRoll (void)
void Ns_Log (Ns_LogSeverity severity, char *fmt,...)
void ns_serverLog (Ns_LogSeverity severity, char *fmt, va_list *vaPtr)
void Ns_Fatal (char *fmt,...)
char * Ns_LogTime2 (char *timeBuf, int gmt)
char * Ns_LogTime (char *timeBuf)
void NsLogOpen (void)
int NsTclLogRollObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
int NsTclLogCtlObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
int NsTclLogObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
void Ns_SetLogFlushProc (Ns_LogFlushProc *procPtr)
void Ns_SetNsLogProc (Ns_LogProc *procPtr)

Define Documentation

#define LOG_DEBUG   4

#define LOG_DEV   8

#define LOG_EXPAND   2

#define LOG_NONOTICE   16

#define LOG_ROLL   1

The following define available flags bits.

#define LOG_USEC   32


Function Documentation

void Ns_Fatal ( char *  fmt,
  ... 
)

----------------------------------------------------------------------

Ns_Fatal --

Spit a message out to the server log with severity level of Fatal, and then terminate the nsd process.

Results: None.

Side effects: WILL CAUSE AOLSERVER TO EXIT!

----------------------------------------------------------------------

char* Ns_InfoErrorLog ( void   ) 

----------------------------------------------------------------------

Ns_InfoErrorLog --

Returns the filename of the log file.

Results: Log file name or NULL if none.

Side effects: None.

----------------------------------------------------------------------

void Ns_Log ( Ns_LogSeverity  severity,
char *  fmt,
  ... 
)

----------------------------------------------------------------------

Ns_Log --

Spit a message out to the server log.

Results: None.

Side effects: None.

----------------------------------------------------------------------

int Ns_LogRoll ( void   ) 

----------------------------------------------------------------------

Ns_LogRoll --

Signal handler for SIG_HUP which will roll the files. Also a tasty snack from Stuckey's.

Results: NS_OK/NS_ERROR

Side effects: Will rename the log file and reopen it.

----------------------------------------------------------------------

char* Ns_LogTime ( char *  timeBuf  ) 

char* Ns_LogTime2 ( char *  timeBuf,
int  gmt 
)

----------------------------------------------------------------------

Ns_LogTime2, Ns_LogTime --

Copy a local or GMT date and time string useful for common log format enties (e.g., nslog).

Results: Pointer to given buffer.

Side effects: Will put data into timeBuf, which must be at least 41 bytes long.

----------------------------------------------------------------------

void ns_serverLog ( Ns_LogSeverity  severity,
char *  fmt,
va_list *  vaPtr 
)

NB: For binary compatibility with previous releases.

void Ns_SetLogFlushProc ( Ns_LogFlushProc *  procPtr  ) 

----------------------------------------------------------------------

Ns_SetLogFlushProc --

Set the proc to call when writing the log. You probably want to have a Ns_RegisterAtShutdown() call too so you can close/finish up whatever special logging you are doing.

Results: None.

Side effects: None.

----------------------------------------------------------------------

void Ns_SetNsLogProc ( Ns_LogProc *  procPtr  ) 

----------------------------------------------------------------------

Ns_SetNsLogProc --

Set the proc to call when adding a log entry.

There are 2 ways to use this override:

1. In conjunction with the Ns_SetLogFlushProc() to use the existing AOLserver buffering and writing system. So when a log message is added it is inserted into the log cache and flushed later through your log flush override. To use this write any logging data to the Ns_DString that is passed into the Ns_Log proc. 2. Without calling Ns_SetLogFlushProc() and handle all buffering and writing directly. LogFlush() will be called as normal but is a no-op because nothing will have been added. Do not write into the Ns_DString passed into the Ns_Log proc in this case.

Results: None.

Side effects: None.

----------------------------------------------------------------------

void NsInitLog ( void   ) 

----------------------------------------------------------------------

NsInitLog --

Initialize the log API and TLS slot.

Results: None.

Side effects: None.

----------------------------------------------------------------------

void NsLogConf ( void   ) 

----------------------------------------------------------------------

NsLogConf --

Config the logging interface.

Results: None.

Side effects: None.

----------------------------------------------------------------------

void NsLogOpen ( void   ) 

----------------------------------------------------------------------

NsLogOpen --

Open the log file. Adjust configurable parameters, too.

Results: None.

Side effects: Configures this module to use the newly opened log file. If LogRoll is turned on in the config file, then it registers a signal callback.

----------------------------------------------------------------------

Open the log and schedule the signal roll.

int NsTclLogCtlObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *CONST  objv[] 
)

----------------------------------------------------------------------

NsTclLogCtlObjCmd --

Implements ns_logctl command to manage log buffering and release.

Results: Tcl result.

Side effects: See docs.

----------------------------------------------------------------------

FALLTHROUGH

int NsTclLogObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *CONST  objv[] 
)

----------------------------------------------------------------------

NsTclLogObjCmd --

Implements ns_log as obj command.

Results: Tcl result.

Side effects: See docs.

----------------------------------------------------------------------

int NsTclLogRollObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *CONST  objv[] 
)

----------------------------------------------------------------------

NsTclLogRollObjCmd --

Implements ns_logroll as obj command.

Results: Tcl result.

Side effects: See docs.

----------------------------------------------------------------------


Generated on Tue Sep 4 19:58:56 2007 by  doxygen 1.5.1