Update of /cvsroot/naviserver/naviserver/nsd
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14198/nsd
Modified Files:
log.c
Log Message:
* nsd/log.c:
* tests/ns_log.test: Add new sub-command: ns_logctl severity.
With this you can query and set the status of any of the log
levels at runtime. For example, you could log into the control
port -- ns_logctl severity debug on -- to track down a problem.
Index: log.c
===================================================================
RCS file: /cvsroot/naviserver/naviserver/nsd/log.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** log.c 16 Oct 2005 08:52:48 -0000 1.10
--- log.c 17 Oct 2005 11:43:58 -0000 1.11
***************
*** 92,96 ****
/*
! * Keep the following in sync with the Ns_LogSeverity enum.
*/
--- 92,99 ----
/*
! * The following table defines which severity levels
! * are currently active.
! *
! * Be sure to keep the order in sync with the Ns_LogSeverity enum.
*/
***************
*** 108,111 ****
--- 111,133 ----
};
+ /*
+ * The following table converts from severity string names to
+ * an Ns_LogSeverity enum value.
+ */
+
+ static struct {
+ char *string;
+ Ns_LogSeverity severity;
+ } severityTable[] = {
+ {"notice", Notice}, {"Notice", Notice},
+ {"warning", Warning}, {"Warning", Warning},
+ {"error", Error}, {"Error", Error},
+ {"fatal", Fatal}, {"Fatal", Fatal},
+ {"bug", Bug}, {"Bug", Bug},
+ {"debug", Debug}, {"Debug", Debug},
+ {"dev", Dev}, {"Dev", Dev},
+ {NULL, 0}
+ };
+
/*
***************
*** 472,485 ****
Tcl_Obj *CONST objv[])
{
! LogCache *cachePtr;
! int len, opt;
static CONST char *opts[] = {
"hold", "count", "get", "peek", "flush", "release",
! "truncate", NULL
};
enum {
CHoldIdx, CCountIdx, CGetIdx, CPeekIdx, CFlushIdx, CReleaseIdx,
! CTruncIdx
};
--- 494,508 ----
Tcl_Obj *CONST objv[])
{
! LogCache *cachePtr;
! int len, opt, i, bool;
! Ns_LogSeverity severity;
static CONST char *opts[] = {
"hold", "count", "get", "peek", "flush", "release",
! "truncate", "severity", NULL
};
enum {
CHoldIdx, CCountIdx, CGetIdx, CPeekIdx, CFlushIdx, CReleaseIdx,
! CTruncIdx, CSeverityIdx
};
***************
*** 529,532 ****
--- 552,576 ----
Ns_DStringTrunc(&cachePtr->buffer, len);
break;
+
+ case CSeverityIdx:
+ if (objc != 3 && objc != 4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "severity-level ?bool?");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIndexFromObjStruct(interp, objv[2], severityTable,
+ sizeof(severityTable[0]), "severity",
+ TCL_EXACT, &i) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ severity = severityTable[i].severity;
+ if (objc == 4) {
+ if (Tcl_GetBooleanFromObj(interp, objv[3], &bool) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ logConfig[severity].enabled = bool;
+ }
+ Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
+ logConfig[severity].enabled);
+ break;
}
***************
*** 559,576 ****
int i;
- struct {
- char *string;
- Ns_LogSeverity severity;
- } severityTable[] = {
- {"notice", Notice}, {"Notice", Notice},
- {"warning", Warning}, {"Warning", Warning},
- {"error", Error}, {"Error", Error},
- {"fatal", Fatal}, {"Fatal", Fatal},
- {"bug", Bug}, {"Bug", Bug},
- {"debug", Debug}, {"Debug", Debug},
- {"dev", Dev}, {"Dev", Dev},
- {NULL, 0}
- };
-
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "severity string ?string ...?");
--- 603,606 ----
|