From: Wilfried Goesgens Date: Sat, 5 May 2012 12:08:49 +0000 (+0200) Subject: LOGGING: add tiny webcit interface to manage log configs X-Git-Tag: v8.11~41 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=652b652cad9114c63dc064cb208d926bd403ca7a LOGGING: add tiny webcit interface to manage log configs --- diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 5cbd56c7d..915097814 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -387,6 +387,73 @@ int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) else return 0; } +/*----------------------------------------------------------------------------* + * Displaying Logging * + *----------------------------------------------------------------------------*/ +typedef struct __LogStatusStruct { + int Enable; + StrBuf *Name; +}LogStatusStruct; + +void DeleteLogStatusStruct(void *v) +{ + LogStatusStruct *Stat = (LogStatusStruct*)v; + + FreeStrBuf(&Stat->Name); + free(Stat); +} + +void tmplput_servcfg_LogName(StrBuf *Target, WCTemplputParams *TP) +{ + LogStatusStruct *Stat = (LogStatusStruct*) CTX; + StrBufAppendTemplate(Target, TP, Stat->Name, 1); +} + +int ConditionalServCfgThisLogEnabled(StrBuf *Target, WCTemplputParams *TP) +{ + LogStatusStruct *Stat = (LogStatusStruct*) CTX; + return Stat->Enable; +} + +HashList *iterate_GetSrvLogEnable(StrBuf *Target, WCTemplputParams *TP) +{ + HashList *Hash = NULL; + StrBuf *Buf; + LogStatusStruct *Stat; + const char *Pos; + int Done = 0; + long len; + int num_logs = 0; + + serv_puts("LOGP"); + Buf = NewStrBuf(); + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) == 1) { + Hash = NewHash(1, Flathash); + while (!Done) { + len = StrBuf_ServGetln(Buf); + if ((len <0) || + ((len == 3) && + !strcmp(ChrPtr(Buf), "000"))) + { + Done = 1; + break; + } + Stat = (LogStatusStruct*) malloc (sizeof(LogStatusStruct)); + Pos = NULL; + Stat->Name = NewStrBufPlain(NULL, len); + StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|'); + Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|'); + + Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct); + num_logs++; + } + } + FreeStrBuf(&Buf); + return Hash; +} + + void InitModule_SITECONFIG (void) @@ -411,6 +478,10 @@ InitModule_SITECONFIG RegisterConditional(HKEY("COND:EXPIRE:MODE"), 2, ConditionalExpire, CTX_NONE); RegisterNamespace("EXPIRE:VALUE", 1, 2, tmplput_ExpireValue, NULL, CTX_NONE); RegisterNamespace("EXPIRE:MODE", 1, 2, tmplput_ExpireMode, NULL, CTX_NONE); + + RegisterConditional(HKEY("COND:SERVCFG:THISLOGENABLE"), 4, ConditionalServCfgThisLogEnabled, CTX_SRVLOG); + RegisterIterator("SERVCFG:LOGENABLE", 0, NULL, iterate_GetSrvLogEnable, NULL, DeleteHash, CTX_SRVLOG, CTX_NONE, IT_NOFLAG); + RegisterNamespace("SERVCFG:LOGNAME", 0, 1, tmplput_servcfg_LogName, NULL, CTX_SRVLOG); } void diff --git a/webcit/static/t/aide/display_logstatus.html b/webcit/static/t/aide/display_logstatus.html new file mode 100644 index 000000000..40a88ee30 --- /dev/null +++ b/webcit/static/t/aide/display_logstatus.html @@ -0,0 +1,21 @@ + + + +
+ + + + + + +
+ +

+
+
+ + diff --git a/webcit/static/t/aide/display_logstatus_line.html b/webcit/static/t/aide/display_logstatus_line.html new file mode 100644 index 000000000..3fbd0cb8a --- /dev/null +++ b/webcit/static/t/aide/display_logstatus_line.html @@ -0,0 +1,8 @@ + + + " + onclick="ToggleLogEnable('')" + > + + diff --git a/webcit/static/t/aide/global_config.html b/webcit/static/t/aide/global_config.html index fe06f7c4d..e8019c769 100644 --- a/webcit/static/t/aide/global_config.html +++ b/webcit/static/t/aide/global_config.html @@ -2,5 +2,6 @@
  • +
  • diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 3308e56f4..c338cb055 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -54,7 +54,28 @@ function strcmp ( str1, str2 ) { return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) ); } - +function CtdlMarkLog($Which, $Status) +{ + if ($Status) + document.getElementById($Which).checked == false; + else + document.getElementById($Which).checked == true; + +} +function ToggleLogEnable($Which) +{ + var p; + var Status = !document.getElementById($Which).checked; + if (Status) + p= encodeURI('g_cmd=LOGS ' + $Which + '|0'); + else + p= encodeURI('g_cmd=LOGS ' + $Which + '|1'); + new Ajax.Request('ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: CtdlMarkLog($Which, Status) + }); +} function ToggleVisibility ($Which) { diff --git a/webcit/subst.c b/webcit/subst.c index 6e5ab6fc6..41a352e68 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -113,6 +113,7 @@ const char *CtxNames[] = { "Context SIEVE Script", "Context MailQ-Item", "Context MailQ-Recipient", + "Context ServLogStatus", "Context UNKNOWN" }; diff --git a/webcit/subst.h b/webcit/subst.h index 3bf491749..b44b33a52 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -64,8 +64,9 @@ enum { #define CTX_SIEVESCRIPT 23 #define CTX_MAILQITEM 24 #define CTX_MAILQ_RCPT 25 +#define CTX_SRVLOG 26 -#define CTX_UNKNOWN 25 +#define CTX_UNKNOWN 27 /**