From 1d7681e3261fba412e08ae2ab52b8ee0ddc62d10 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Wed, 10 Apr 2013 19:49:19 +1000 Subject: [PATCH] Reduce verbosity of log files when using JSON protocol. --- protocol.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/protocol.c b/protocol.c index c85f7138..e1c87863 100644 --- a/protocol.c +++ b/protocol.c @@ -489,9 +489,12 @@ int SCWriteSycamore(SConnection * pCon, char *pBuffer, int iOut) return 0; } - snprintf(pBueffel,sizeof(pBueffel)-1, "Next line intended for socket: %d", pCon->sockHandle); - SICSLogWrite(pBueffel, eInternal); - SICSLogWrite(pBuffer, iOut); + iRet=snprintf(pBueffel,sizeof(pBueffel)-1, "[%d]:%s", pCon->sockHandle, pBuffer); + SICSLogWrite(pBueffel, iOut); + if (iRet >= MAXMSG) { + snprintf(pBueffel,sizeof(pBueffel)-1, "TRUNCATED MESSAGE: message len=%d, MAXMSG=%d",strlen(pBuffer), MAXMSG); + SICSLogWrite(pBueffel, eError); + } /* write to commandlog if user or manager privilege */ if (SCGetRights(pCon) <= usUser) { @@ -683,10 +686,13 @@ int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut) if (strlen(pBuffer) == 0) return 1; - if (pCon->iMacro != 1) { - snprintf(pBueffel,sizeof(pBueffel)-1, "Next line intended for socket: %d", pCon->sockHandle); - SICSLogWrite(pBueffel, eInternal); - SICSLogWrite(pBuffer, iOut); + if (!SCinMacro(pCon)) { + iRet=snprintf(pBueffel,sizeof(pBueffel)-1, "[%d]:%s", pCon->sockHandle, pBuffer); + SICSLogWrite(pBueffel, iOut); + if (iRet >= MAXMSG) { + snprintf(pBueffel,sizeof(pBueffel)-1, "TRUNCATED MESSAGE: message len=%d, MAXMSG=%d",strlen(pBuffer), MAXMSG); + SICSLogWrite(pBueffel, eError); + } } /* write to commandlog if user or manager privilege */