+ add non-TP-Related Wildfire enabled error logging function
authorWilfried Göesgens <willi@citadel.org>
Wed, 25 Feb 2009 22:13:48 +0000 (22:13 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 25 Feb 2009 22:13:48 +0000 (22:13 +0000)
* use that when reporting weird message headers

webcit/messages.c
webcit/subst.c
webcit/subst.h

index a913b254dd5842ca9f4c576b834e4c02285921bf..d60b2eefb9ecf4647418774814a6a4f1daeb394a 100644 (file)
@@ -122,7 +122,10 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
                                        state++;
                                }
                        }
-                       else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(HdrToken));
+                       else LogError(Target, 
+                                     __FUNCTION__,  
+                                     "don't know how to handle message header[%s]\n", 
+                                     ChrPtr(HdrToken));
                        break;
                case 1:/* Message Mime Header */
                        if (StrLength(Buf) == 0) {
index c4abfc890612b69b1700e01ce77bb1d3531b85e8..6848f58d04fb9b386886fbf4eee87a3931b79c60 100644 (file)
@@ -172,8 +172,10 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
                        Type, 
                        ChrPtr(Error));
        }
+/*
        if (Target == NULL) 
                return;
+*/
        WCC = WC;
        Header = NewStrBuf();
        if (TP->Tokens != NULL) 
@@ -235,6 +237,45 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
 }
 
 
+
+
+void LogError (StrBuf *Target, const char *Type, const char *Format, ...)
+{
+       wcsession *WCC;
+       StrBuf *Header;
+       StrBuf *Error;
+       StrBuf *Info;
+        va_list arg_ptr;
+
+       Info = NewStrBuf();
+       Error = NewStrBuf();
+
+        va_start(arg_ptr, Format);
+       StrBufVAppendPrintf(Error, Format, arg_ptr);
+       va_end(arg_ptr);
+
+       lprintf(1, ChrPtr(Error));
+
+       WCC = WC;
+       Header = NewStrBuf();
+
+
+       SerializeJson(Header, WildFireException(Type, strlen(Type),
+                                               0,
+                                               Info,
+                                               1), 1);
+       WildFireSerializePayload(Header, WCC->HBuf, &WCC->nWildfireHeaders, NULL);
+       
+       FreeStrBuf(&Header);
+       FreeStrBuf(&Info);
+       FreeStrBuf(&Error);
+/*
+       if (dbg_bactrace_template_errors)
+               wc_backtrace(); 
+*/
+}
+
+
 void RegisterNS(const char *NSName, 
                long len, 
                int nMinArgs, 
index ad8fb61b54d55cf98b5dae192e422d449aece903..a45dfb2582e08f61cac3ffaa4cde23490df3641b 100644 (file)
@@ -1,4 +1,4 @@
-
+\
 extern HashList *Conditionals;
 extern HashList *GlobalNS;
 extern HashList *Iterators;
@@ -177,6 +177,15 @@ void LogTemplateError (StrBuf *Target,
                       WCTemplputParams *TP, 
                       const char *Format, ...)__attribute__((__format__(__printf__,5,6)));
 
+
+/**
+ * \Brief log an error while in global context; print it to Wildfire / Target
+ * \param Target your Target Buffer to print the error message next to the log
+ * \param Type What sort of thing are we talking about? Tokens? Conditionals?
+ * \param Format for the custom error message
+ */ 
+void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
+
 /**
  * \Brief get the actual value of a token parameter
  * in your tmplputs or conditionals use this function to access parameters that can also be