tcl-websh-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ron...@apache.org
Subject svn commit: r788707 - in /tcl/websh/trunk: ./ doc/ src/ src/generic/ src/tests/
Date Fri, 26 Jun 2009 14:04:40 GMT
Author: ronnie
Date: Fri Jun 26 14:04:40 2009
New Revision: 788707

URL: http://svn.apache.org/viewvc?rev=788707&view=rev
Log:
- Added [web::config safelog] configuration to allow web::log to properly
  throw errors if I/O fails (if safelog is set to 0). Default is 1 to ensure
  backward compatibility.
- Fixed log handling for logtochannel plugin: reliable channel handling
- Added tests for new web::log error handling

Refer to src/ChangeLog for details

Modified:
    tcl/websh/trunk/CHANGES
    tcl/websh/trunk/doc/quickref.xml
    tcl/websh/trunk/doc/quickref.xsl
    tcl/websh/trunk/src/ChangeLog
    tcl/websh/trunk/src/generic/cfg.c
    tcl/websh/trunk/src/generic/log.c
    tcl/websh/trunk/src/generic/log.h
    tcl/websh/trunk/src/generic/logtochannel.c
    tcl/websh/trunk/src/generic/logtochannel.h
    tcl/websh/trunk/src/generic/logtofile.c
    tcl/websh/trunk/src/generic/logutl.c
    tcl/websh/trunk/src/tests/cfg.test
    tcl/websh/trunk/src/tests/logtochannel.test
    tcl/websh/trunk/src/tests/logtocmd.test

Modified: tcl/websh/trunk/CHANGES
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/CHANGES?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/CHANGES (original)
+++ tcl/websh/trunk/CHANGES Fri Jun 26 14:04:40 2009
@@ -9,6 +9,12 @@
 Trunk
 -----
 
+- Added [web::config safelog] configuration to allow web::log to properly
+  throw errors if I/O fails (if safelog is set to 0). Default is 1 to ensure
+  backward compatibility.
+
+- Fixed log handling for logtochannel plugin: reliable channel handling
+
 - Added simple pkgIndex.tcl to installation
 
 - Bug fix in web::cmdurl when using -urlformat

Modified: tcl/websh/trunk/doc/quickref.xml
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/doc/quickref.xml?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/doc/quickref.xml (original)
+++ tcl/websh/trunk/doc/quickref.xml Fri Jun 26 14:04:40 2009
@@ -98,8 +98,8 @@
 	  <term><option>cmdparam</option> <optional><option><replaceable>name</replaceable></option></optional></term>
 	  <listitem>
 	    <para>
-	      Name of the <command>web::command</command> parameter in
-	      the URL. Default: &quot;cmd&quot;.
+	      Name of the command  parameter in
+	      the URL used to dispatch to <command>web::command</command> using <command>web::dispatch</command>.
Default: &quot;cmd&quot;.
 	    </para>
 	  </listitem>
 	</varlistentry>
@@ -117,16 +117,24 @@
 	  <listitem>
 	    <para>
 	      Defines whether the timestamp should be included in URLs 
-              generated by <command>web::cmdurl</command>. Default: 1
+              generated by <command>web::cmdurl</command>. Default: 1 (yes)
 	    </para>
 	  </listitem>
 	</varlistentry>
 	<varlistentry>
-	  <term><option>logsubst</option> <optional><option>boolean</option></optional></term>
+	  <term><option>logsubst</option> <optional><option>0|1</option></optional></term>
 	  <listitem>
 	    <para>
-	      Turns substitution of log messages on or off. Default:
-	      off.
+	      Turns substitution of log messages on (1) or off (0). Default:
+	      0 (off).
+	    </para>
+	  </listitem>
+	</varlistentry>
+	<varlistentry>
+	  <term><option>safelog</option> <optional><option>0|1</option></optional></term>
+	  <listitem>
+	    <para>
+	      Makes web::log &quot;safe&quot; if set to 1 (i.e. it never throws an error
even if corresponding I/O to file, channel or command etc. fails). Default: 1 (on).
 	    </para>
 	  </listitem>
 	</varlistentry>
@@ -138,7 +146,7 @@
 	      Sets the markup characters for sections to be eval'd in
 	      <command>web::putx</command> and <command>web::putxfile</command>
               commands to either curly braces ({ ... }) or special tags (&lt;?
-	      ... ?&gt;). Default: brace.
+	      ... ?&gt;). Default: &quot;brace&quot;.
 	    </para>
 	  </listitem>
 	</varlistentry>
@@ -1743,7 +1751,7 @@
 	  Option is: <option>-unbuffered</option>
 	</para>
 	<para>
-Log messages are sent to the file <option>filename</option>, which is opened
at in append mode at time of this calls and stys open until this destination is deleted. This
is either at the end of the request (mod_websh) or when the interpreter is deleted.
+Log messages are sent to the file <option>filename</option>, which is opened
in append mode at the time of this call and stays open until this destination is deleted.
This is either at the end of the request (mod_websh) or when the interpreter is deleted.
 	</para>
 	<para>
 The file opened using the permissions configured with <command>web::config filepermissions</command>.
Default is 0644.
@@ -2293,7 +2301,7 @@
 		(i.e. cookie expires in 24 hours. (Please note that the
 		behavior of some of these relative time specifiers changed
 		from Tcl8.4 to Tcl8.5.) Use
-		<emphasis>-expires ""</emphasis> to 
+		<emphasis>-expires &quot;&quot;</emphasis> to 
 		send a cookie without an expires parameter.
 	      </para>
 	    </listitem>

Modified: tcl/websh/trunk/doc/quickref.xsl
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/doc/quickref.xsl?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/doc/quickref.xsl (original)
+++ tcl/websh/trunk/doc/quickref.xsl Fri Jun 26 14:04:40 2009
@@ -23,7 +23,7 @@
   <!-- ==================================================================== -->
 
   <xsl:import
-    href="http://docbook.sourceforge.net/release/xsl/1.74.0/html/chunk.xsl"
+    href="http://docbook.sourceforge.net/release/xsl/1.75.1/html/chunk.xsl"
   />
   <!-- local alternatives to the network URL for faster processing 
   <xsl:import

Modified: tcl/websh/trunk/src/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/ChangeLog?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/ChangeLog (original)
+++ tcl/websh/trunk/src/ChangeLog Fri Jun 26 14:04:40 2009
@@ -1,3 +1,31 @@
+2009-06-26 Brunner Ronnie <ronnie.brunner@netcetera.ch>
+	* doc/quickref.xml:
+	- Fixed minor typos
+	- Added documentation of [web::config safelog]
+	* doc/quickref.xsl:
+	- Reference to newer docbook version
+	* src/generic/cfg.c, src/generic/log.c, src/generic/log.h:
+	- Added [web::config safelog] with default 1 to explicitly allow
+	  web::log to throw an error if I/O fails (if safelog is set to 0)
+	* src/generic/logutl.c, src/generic/log.h:
+	- Properly report and pass errors during logging if 
+	  [web::config safelog] is set accordingly
+	  (sendMsgToDestList now returns TCL_OK/TCL_ERROR instead of void)
+	* src/generic/logtochannel.c, src/generic/logtochannel.h:
+	- Properly handle cases when channel is not available (anymore), i.e.
+	  Tcl_GetChannel for every log message and when destination is deleted
+	  instead of only getting channel initially and then produce a segfault
+	  if channel is gone.
+	* src/generic/logtofile.c:
+	- Properly track Tcl_Flush errors
+	* src/test/cfg.test:
+	- Fixed test cfg-1.1 to pass with newsafelog subcommand
+	- New test for [web::config safelog]
+	* src/tests/logtocmd.test:
+	- Added test for error in command and [web::config safelog]
+	* src/tests/logtochannel.test:
+	- Added test for closed channel and [web::config safelog]
+
 2009-06-17 Brunner Ronnie <ronnie.brunner@netcetera.ch>
 	* doc/mod_websh/README, src/win/README:
 	- Properly document that shared lib libwebsh.so (websh.dll) is

Modified: tcl/websh/trunk/src/generic/cfg.c
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/cfg.c?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/cfg.c (original)
+++ tcl/websh/trunk/src/generic/cfg.c Fri Jun 26 14:04:40 2009
@@ -132,6 +132,7 @@
 	"timeparam",
 	"putxmarkup",
 	"logsubst",
+	"safelog",
 	"version",
 	"copyright",
 	"cmdurltimestamp",
@@ -153,6 +154,7 @@
 	TIMETAG,
 	PUTXMARKUP,
 	LOGSUBST,
+	SAFELOG,
 	WEBSHVERSION,
 	WEBSHCOPYRIGHT,
 	CMDURLTIMESTAMP,
@@ -435,6 +437,29 @@
 	    return TCL_ERROR;
 	}
 	return TCL_OK;
+    case SAFELOG:
+	Tcl_SetObjResult(interp,
+			 Tcl_NewBooleanObj(cfgData->logData->safeLog));
+	switch (objc) {
+	case 2:
+	    break;
+	case 3:
+	    /* --------------------------------------------------------------------
+	     * only accept integers
+	     * ----------------------------------------------------------------- */
+	    if (Tcl_GetBooleanFromObj(interp, objv[2],
+				      &(cfgData->logData->safeLog)) ==
+		TCL_ERROR)
+		return TCL_ERROR;
+	    break;
+	default:
+	    LOG_MSG(interp, WRITE_LOG | SET_RESULT,
+		    __FILE__, __LINE__,
+		    "web::config safelog", WEBLOG_INFO,
+		    "usage: web::config safelog ?boolean?", NULL);
+	    return TCL_ERROR;
+	}
+	return TCL_OK;
     case WEBSHVERSION:{
 	    WebAssertObjc(objc != 2, 2, NULL);
 
@@ -521,6 +546,7 @@
 	Tcl_DecrRefCount(tmp);
 
 	cfgData->logData->logSubst = LOG_SUBSTDEFAULT;
+	cfgData->logData->safeLog = LOG_SAFEDEFAULT;
 
 	Tcl_ResetResult(interp);
 

Modified: tcl/websh/trunk/src/generic/log.c
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/log.c?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/log.c (original)
+++ tcl/websh/trunk/src/generic/log.c Fri Jun 26 14:04:40 2009
@@ -153,6 +153,7 @@
 
 	HashUtlAllocInit(logData->listOfPlugIns, TCL_STRING_KEYS);
 	logData->logSubst = LOG_SUBSTDEFAULT;
+	logData->safeLog = LOG_SAFEDEFAULT;
 	logData->keep = 0;
     }
 

Modified: tcl/websh/trunk/src/generic/log.h
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/log.h?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/log.h (original)
+++ tcl/websh/trunk/src/generic/log.h Fri Jun 26 14:04:40 2009
@@ -89,6 +89,7 @@
 #define LOG_FILTER_PREFIX "loglevel"
 #define LOG_DEST_PREFIX "logdest"
 #define LOG_SUBSTDEFAULT 0
+#define LOG_SAFEDEFAULT 1
 
 /* ----------------------------------------------------------------------------
  * list of possible categories
@@ -168,6 +169,7 @@
   int destSize; /* site of destination list */
   Tcl_HashTable *listOfPlugIns;
   int logSubst;	/* 1: subst log message, 0: don't (default 0) */
+  int safeLog;	/* 1: web::log never fails, 0: can throw I/O error (default 1) */
   int keep;  /* flag for log config to keep during initializer code */
   /* needed so that global settings can be accessed */
   RequestData * requestData;
@@ -207,7 +209,7 @@
 	    char *levelStr, Tcl_Obj * msg);
 int webLog(Tcl_Interp * interp, char *levelStr, char *msg);
 
-void sendMsgToDestList(Tcl_Interp * interp,
+int sendMsgToDestList(Tcl_Interp * interp,
 		       LogData * logData, LogLevel * level, Tcl_Obj * msg);
 
 char * insertIntoDestList(LogData *logData, LogDest *logDest);

Modified: tcl/websh/trunk/src/generic/logtochannel.c
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/logtochannel.c?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/logtochannel.c (original)
+++ tcl/websh/trunk/src/generic/logtochannel.c Fri Jun 26 14:04:40 2009
@@ -29,9 +29,7 @@
     LogToChannelData *logToChannelData = NULL;
 
     logToChannelData = WebAllocInternalData(LogToChannelData);
-    logToChannelData->channel = NULL;
     logToChannelData->channelName = NULL;
-    logToChannelData->mode = 0;
     logToChannelData->isBuffered = TCL_OK;
 
     return logToChannelData;
@@ -47,8 +45,16 @@
     if ((interp == NULL) || (logToChannelData == NULL))
 	return TCL_ERROR;
 
-    if (logToChannelData->channel != NULL)
-	Tcl_Flush(logToChannelData->channel);
+    if (logToChannelData->channelName != NULL) {
+      int mode;
+      Tcl_Channel channel = NULL;
+      channel = Tcl_GetChannel(interp, logToChannelData->channelName, &mode);
+
+      if (channel != NULL)
+	if (mode & TCL_WRITABLE)
+	  Tcl_Flush(channel);
+
+    }
 
     WebFreeIfNotNull(logToChannelData->channelName);
     WebFreeIfNotNull(logToChannelData);
@@ -126,9 +132,7 @@
     /* --------------------------------------------------------------------------
      * and set values
      * ----------------------------------------------------------------------- */
-    logToChannelData->channel = channel;
     logToChannelData->channelName = allocAndSet(channelName);
-    logToChannelData->isBuffered = mode;
     if (argKeyExists(objc, objv, "-unbuffered") == TCL_OK)
 	logToChannelData->isBuffered = TCL_ERROR;
     else
@@ -159,14 +163,33 @@
 
     logToChannelData = (LogToChannelData *) clientData;
 
-    /* No seek function because it might well not exist, and we ought
-     * to be at the end anyway. */
+    /* get channel every time, as it might have been closed
+       and this can only be detected that way */
+    if (logToChannelData->channelName != NULL) {
+      int mode;
+      Tcl_Channel channel = NULL;
+      channel = Tcl_GetChannel(interp, logToChannelData->channelName, &mode);
+      
+      if (channel == NULL) {
+	return TCL_ERROR;
+      }
 
-    res = Tcl_WriteChars(logToChannelData->channel, msg, -1);
-    if (res < 0)
+      if (!(mode & TCL_WRITABLE)) {
 	return TCL_ERROR;
-    if (logToChannelData->isBuffered == TCL_ERROR)
-	Tcl_Flush(logToChannelData->channel);
+      }
+      
+      /* No seek function because it might well not exist, and we ought
+       * to be at the end anyway. */
 
-    return TCL_OK;
+      res = Tcl_WriteChars(channel, msg, -1);
+      if (res < 0)
+	return TCL_ERROR;
+      if (logToChannelData->isBuffered == TCL_ERROR)
+	return Tcl_Flush(channel);
+
+      return TCL_OK;
+
+    } else {
+      return TCL_ERROR;
+    }
 }

Modified: tcl/websh/trunk/src/generic/logtochannel.h
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/logtochannel.h?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/logtochannel.h (original)
+++ tcl/websh/trunk/src/generic/logtochannel.h Fri Jun 26 14:04:40 2009
@@ -23,9 +23,7 @@
  * ------------------------------------------------------------------------- */
 typedef struct LogToChannelData
 {
-    Tcl_Channel channel;
     char *channelName;
-    int mode;			/* TCL_READABLE || TCL_WRITEABLE */
     char isBuffered;
 }
 LogToChannelData;

Modified: tcl/websh/trunk/src/generic/logtofile.c
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/logtofile.c?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/logtofile.c (original)
+++ tcl/websh/trunk/src/generic/logtofile.c Fri Jun 26 14:04:40 2009
@@ -157,7 +157,7 @@
     if (res < 0)
 	return TCL_ERROR;
     if (logToFileData->isBuffered == TCL_ERROR)
-	Tcl_Flush(logToFileData->channel);
+	return Tcl_Flush(logToFileData->channel);
 
     return TCL_OK;
 }

Modified: tcl/websh/trunk/src/generic/logutl.c
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/generic/logutl.c?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/logutl.c (original)
+++ tcl/websh/trunk/src/generic/logutl.c Fri Jun 26 14:04:40 2009
@@ -79,13 +79,14 @@
  * 2: internal data
  * 3: log level definition, like "test.info-alert"
  * 4: message, including special tags
- * R: TCL_OK in any case
+ * R: TCL_OK if [web::config safelog] is set to 1 actual result otherwise
  * ------------------------------------------------------------------------- */
 int logImpl(Tcl_Interp * interp, LogData * logData,
 	    char *levelStr, Tcl_Obj * msg)
 {
 
     LogLevel *logLevel = NULL;
+    int res;
 
     if ((logData == NULL) || (levelStr == NULL) || (msg == NULL))
 	return TCL_ERROR;
@@ -98,17 +99,21 @@
      * does level pass the filters --> send to dests
      * --------------------------------------------------------------- */
     if (doesPassFilters(logLevel, logData->listOfFilters, logData->filterSize) == TCL_OK)
-	sendMsgToDestList(interp, logData, logLevel, msg);
+      res = sendMsgToDestList(interp, logData, logLevel, msg);
 
     destroyLogLevel(logLevel, NULL);
 
-    return TCL_OK;
+    /* in case we log safely, always return TCL_OK */
+    if (logData->safeLog == 1)
+      return TCL_OK;
+
+    return res;
 }
 
 /* ----------------------------------------------------------------------------
  * sendMsgToDestList --
  * ------------------------------------------------------------------------- */
-void sendMsgToDestList(Tcl_Interp * interp, LogData * logData,
+int sendMsgToDestList(Tcl_Interp * interp, LogData * logData,
 		       LogLevel * logLevel, Tcl_Obj * msg)
 {
 
@@ -214,8 +219,9 @@
 		    /* ------------------------------------------------------------------
 		     * and send it to the handler
 		     * --------------------------------------------------------------- */
-		    logDest->plugIn->handler(interp, logDest->plugInData,
-					     Tcl_GetString(fmsg));
+		    if (logDest->plugIn->handler(interp, logDest->plugInData,
+						 Tcl_GetString(fmsg)) != TCL_OK)
+		      err++;
 
 		    Tcl_DecrRefCount(fmsg);
 		}
@@ -225,6 +231,9 @@
     if (emsg != NULL) {
 	Tcl_DecrRefCount(emsg);	/* need it no longer */
     }
+    if (err > 0)
+      return TCL_ERROR;
+    return TCL_OK;
 }
 
 

Modified: tcl/websh/trunk/src/tests/cfg.test
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/tests/cfg.test?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/tests/cfg.test (original)
+++ tcl/websh/trunk/src/tests/cfg.test Fri Jun 26 14:04:40 2009
@@ -26,7 +26,7 @@
 test cfg-1.1 {wrong subcommand} {
     catch {web::config foo bar} msg
     set msg
-} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam,
putxmarkup, logsubst, version, copyright, cmdurltimestamp, reset, script, server_root, document_root,
interpclass, or filepermissions}
+} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam,
putxmarkup, logsubst, safelog, version, copyright, cmdurltimestamp, reset, script, server_root,
document_root, interpclass, or filepermissions}
 
 
 test cfg-1.2 {invalid value} {
@@ -52,13 +52,13 @@
 
 test cfg-2.2a {return values when new value is set and reset} {
     set res {}
-    lappend res [list [web::config uploadfilesize 1] [web::config cmdparam page] [web::config
timeparam f] [web::config cmdurltimestamp 0] [web::config logsubst 1] [web::config putxmarkup
tag] [web::config encryptchain foo] [web::config decryptchain bar]]
-    lappend res [list [web::config uploadfilesize 2] [web::config cmdparam c] [web::config
timeparam g] [web::config cmdurltimestamp] [web::config logsubst] [web::config putxmarkup]
[web::config encryptchain] [web::config decryptchain]]
+    lappend res [list [web::config uploadfilesize 1] [web::config cmdparam page] [web::config
timeparam f] [web::config cmdurltimestamp 0] [web::config logsubst 1] [web::config safelog
0] [web::config putxmarkup tag] [web::config encryptchain foo] [web::config decryptchain bar]]
+    lappend res [list [web::config uploadfilesize 2] [web::config cmdparam c] [web::config
timeparam g] [web::config cmdurltimestamp] [web::config logsubst] [web::config safelog] [web::config
putxmarkup] [web::config encryptchain] [web::config decryptchain]]
     lappend res [list [web::config uploadfilesize] [web::config cmdparam] [web::config timeparam]]
     web::config reset
-    lappend res [list [web::config uploadfilesize] [web::config cmdparam] [web::config timeparam]
[web::config cmdurltimestamp] [web::config logsubst] [web::config putxmarkup] [web::config
encryptchain] [web::config decryptchain]]
+    lappend res [list [web::config uploadfilesize] [web::config cmdparam] [web::config timeparam]
[web::config cmdurltimestamp] [web::config logsubst] [web::config safelog] [web::config putxmarkup]
[web::config encryptchain] [web::config decryptchain]]
 
-} {{0 cmd t 1 0 brace web::encryptd web::decryptd} {1 page f 0 1 tag foo bar} {2 c g} {0
cmd t 1 0 brace web::encryptd web::decryptd}}
+} {{0 cmd t 1 0 1 brace web::encryptd web::decryptd} {1 page f 0 1 0 tag foo bar} {2 c g}
{0 cmd t 1 0 1 brace web::encryptd web::decryptd}}
 
 test cfg-2.3 {crypt default} {
     set res [web::config encryptchain [list a b]]

Modified: tcl/websh/trunk/src/tests/logtochannel.test
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/tests/logtochannel.test?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/tests/logtochannel.test (original)
+++ tcl/websh/trunk/src/tests/logtochannel.test Fri Jun 26 14:04:40 2009
@@ -56,5 +56,31 @@
     set res
 } {Ok}
 
+test logToChannel-2.1 {closed channel} {
+    web::logdest delete
+    web::loglevel delete
+    set fileName "tochannel-2.1-[pid].dat"
+    set fh [open $fileName "a"]
+    web::logdest add *.-debug channel -unbuffered $fh
+    web::loglevel add *.-debug
+    web::log debug "Hi there"
+    flush $fh
+    close $fh
+    set msg ""
+    web::config safelog 0
+    set c [catch {web::log debug "Bye there"} msg]
+    web::config safelog 1
+    set c2 [catch {web::log debug "Safe Bye"} msg]
+    set res [web::log debug "Safe Bye 2"]
+    web::readfile $fileName log
+    file delete $fileName
+    regsub -all {.*debug: } $log "" log
+    regsub -all {\".*\"} $msg {"channel"} msg
+    regsub -all {\".*\"} $res {"channel"} res
+    set res "$c - $c2 - $log$msg\n$res"
+} {1 - 0 - Hi there
+can not find channel named "channel"
+can not find channel named "channel"}
+
 # cleanup
 ::tcltest::cleanupTests

Modified: tcl/websh/trunk/src/tests/logtocmd.test
URL: http://svn.apache.org/viewvc/tcl/websh/trunk/src/tests/logtocmd.test?rev=788707&r1=788706&r2=788707&view=diff
==============================================================================
--- tcl/websh/trunk/src/tests/logtocmd.test (original)
+++ tcl/websh/trunk/src/tests/logtocmd.test Fri Jun 26 14:04:40 2009
@@ -45,5 +45,30 @@
     set res [web::log info2.info $curTim]
 } {testLogHandler -- T E S T -- ok}
 
+proc testLogHandler {msg} {
+    return Bar
+}
+
+test logToCmd-2.1 {logToCmd: test log to command error} {
+    web::logdest delete
+    web::loglevel delete
+    web::logdest add info2.-debug command testLogHandler
+    web::loglevel add info2.-debug
+    set res [web::log info2.info Foo]
+    proc testLogHandler {msg other} {
+	return "$msg $other"
+    }
+    set msg ""
+    web::config safelog 0
+    set c [catch {web::log info2.info Zoo} msg]
+    web::config safelog 1
+    proc testLogHandler {msg} {
+	return "$msg $other"
+    }
+    set c2 [catch {web::log info2.info Quo} omsg]
+    set r2 [web::log info2.info Mup]
+    set msg "$c - $c2 - $res - $msg - $r2"
+} {1 - 0 - Bar - wrong # args: should be "testLogHandler msg other" - can't read "other":
no such variable}
+
 # cleanup
 ::tcltest::cleanupTests



---------------------------------------------------------------------
To unsubscribe, e-mail: websh-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-cvs-help@tcl.apache.org


Mime
View raw message