Explorar o código

HPCC-21521 JLIB - Make sure audience and message class is sensible

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Shamser Ahmed %!s(int64=6) %!d(string=hai) anos
pai
achega
44dd486ba8

+ 5 - 5
system/jlib/jargv.cpp

@@ -48,7 +48,7 @@ bool processArgvFilenamesFromFile(IFileArray & filenames, const char * filename)
     FILE * in = fopen(filename, "r");
     if (!in)
     {
-        ERRLOG("Error: File '%s' does not exist", filename);
+        UERRLOG("Error: File '%s' does not exist", filename);
         return false;
     }
 
@@ -90,7 +90,7 @@ bool processArgvFilename(IFileArray & filenames, const char * filename)
         Owned<IFile> cur = createIFile(filename);
         if (cur->isFile() != foundYes)
         {
-            ERRLOG("Error: File '%s' does not exist", filename);
+            UERRLOG("Error: File '%s' does not exist", filename);
             return false;
         }
         filenames.append(*cur.getClear());
@@ -124,7 +124,7 @@ bool ArgvIterator::matchOption(StringAttr & value, const char * name)
         return true;
     }
 
-    ERRLOG("Error: Need to supply a value for %s", arg);
+    UERRLOG("Error: Need to supply a value for %s", arg);
     return false;
 }
 
@@ -159,7 +159,7 @@ bool ArgvIterator::matchFlag(StringAttr & value, const char * name)
         return true;
     }
 
-    ERRLOG("Error: %s needs to supply an associated value", arg);
+    UERRLOG("Error: %s needs to supply an associated value", arg);
     return false;
 }
 
@@ -213,7 +213,7 @@ bool ArgvIterator::matchPathFlag(StringBuffer & option, const char * name)
         return true;
     }
 
-    ERRLOG("Error: %s needs to specify a directory", arg);
+    UERRLOG("Error: %s needs to specify a directory", arg);
     return false;
 }
 

+ 3 - 3
system/jlib/jarray.cpp

@@ -77,7 +77,7 @@ void Allocator::_reallocate(aindex_t newLen, size32_t itemSize)
         newMax = (newLen + DOUBLE_LIMIT) & ~(DOUBLE_LIMIT-1);
         if (newLen >= newMax) // wraparound
         {
-            PrintLog("Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, newLen);
+            IERRLOG("Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, newLen);
             throw MakeStringException(0, "Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items",itemSize, newLen);
         }
     }
@@ -89,13 +89,13 @@ void Allocator::_reallocate(aindex_t newLen, size32_t itemSize)
     size_t allocSize = (size_t)itemSize * newMax;
     if (allocSize < newMax)
     {
-        PrintLog("Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, newLen);
+        IERRLOG("Out of memory (overflow) in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, newLen);
         throw MakeStringException(0, "Out of memory (overflow) in Array allocator: itemSize = %u, trying to allocate %u items",itemSize, newLen);
     }
     void *newhead = realloc(_head, allocSize);
     if (!newhead) 
     {
-        PrintLog("Out of memory in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, max);
+        IERRLOG("Out of memory in Array allocator: itemSize = %d, trying to allocate %d items", itemSize, max);
         throw MakeStringException(0, "Out of memory in Array allocator: itemSize = %d, trying to allocate %d items",itemSize, max);
     }
     max = newMax;

+ 4 - 4
system/jlib/jbsocket.cpp

@@ -172,7 +172,7 @@ int BufferedSocket::readline(char* buf, int maxlen, bool keepcrlf, IMultiExcepti
             case JSOCKERR_connectionless_socket: //= -9,    // accept, cancel_accept
             default:
             {
-                ERRLOG("In BufferedSocket::readline() -- Exception(%d, %s) reading from socket(%d).", e->errorCode(), e->errorMessage(estr).str(), m_socket->OShandle());
+                IERRLOG("In BufferedSocket::readline() -- Exception(%d, %s) reading from socket(%d).", e->errorCode(), e->errorMessage(estr).str(), m_socket->OShandle());
                 break;
             }
         }
@@ -185,7 +185,7 @@ int BufferedSocket::readline(char* buf, int maxlen, bool keepcrlf, IMultiExcepti
     }
     catch(...)
     {
-        ERRLOG("In BufferedSocket::readline() -- Unknown exception reading from socket(%d).", m_socket->OShandle());
+        IERRLOG("In BufferedSocket::readline() -- Unknown exception reading from socket(%d).", m_socket->OShandle());
         return -1;
     }
     
@@ -255,7 +255,7 @@ int BufferedSocket::read(char* buf, int maxlen)
                     case JSOCKERR_connectionless_socket: //= -9,    // accept, cancel_accept
                     default:
                     {
-                        ERRLOG("In BufferedSocket::readline() -- Exception(%d, %s) reading from socket(%d).", e->errorCode(), e->errorMessage(estr).str(), m_socket->OShandle());
+                        IERRLOG("In BufferedSocket::readline() -- Exception(%d, %s) reading from socket(%d).", e->errorCode(), e->errorMessage(estr).str(), m_socket->OShandle());
                         break;
                     }
                 }
@@ -265,7 +265,7 @@ int BufferedSocket::read(char* buf, int maxlen)
             }
             catch(...)
             {
-                ERRLOG("In BufferedSocket::read() -- Unknown exception reading from socket(%d).", m_socket->OShandle());
+                IERRLOG("In BufferedSocket::read() -- Unknown exception reading from socket(%d).", m_socket->OShandle());
                 return -1;
             }
 

+ 10 - 13
system/jlib/jcomp.cpp

@@ -133,8 +133,8 @@ static void doSetCompilerPath(const char * path, const char * includes, const ch
         libs = LIB_DIR[targetCompiler];
     if (verbose)
     {
-        PrintLog("Include directory set to %s", includes);
-        PrintLog("Library directory set to %s", libs);
+        DBGLOG("Include directory set to %s", includes);
+        DBGLOG("Library directory set to %s", libs);
     }
     compilerRoot.set(path ? path : targetCompiler==GccCppCompiler ? "/usr" : ".\\CL");
     stdIncludes.set(includes);
@@ -188,7 +188,7 @@ static void doSetCompilerPath(const char * path, const char * includes, const ch
         fname.replaceString("#",NULL);
     }
     if (verbose)
-        PrintLog("Compiler path set to %s", fname.str());
+        LOG(MCoperatorInfo, "Compiler path set to %s", fname.str());
 
     dequote(fname);
 #ifdef _WIN32
@@ -206,7 +206,7 @@ static void doSetCompilerPath(const char * path, const char * includes, const ch
 #endif
 #endif
         if (verbose)
-            PrintLog("SetCompilerPath - no compiler found");
+            LOG(MCoperatorInfo, "SetCompilerPath - no compiler found");
         throw makeOsExceptionV(GetLastError(), "setCompilerPath could not locate compiler %s", fname.str());
     }
 
@@ -302,7 +302,7 @@ void CppCompiler::addDefine(const char * symbolName, const char * value)
 void CppCompiler::addLibrary(const char * libName)
 {
     if (verbose)
-        PrintLog("addLibrary %s", libName);
+        LOG(MCuserInfo, "addLibrary %s", libName);
 
     const char* lname = libName;
     const char * quote;
@@ -421,10 +421,10 @@ bool CppCompiler::compile()
             {
                 if (abortChecker && abortChecker->abortRequested())
                 {
-                    PrintLog("Aborting compilation");
+                    UERRLOG("Aborting compilation");
                     pool->stopAll(true);
                     if (!pool->joinAll(true, 10*1000))
-                        WARNLOG("CCompilerWorker; timed out waiting for threads in pool");
+                        IWARNLOG("CCompilerWorker; timed out waiting for threads in pool");
                     return false;
                 }
             }
@@ -531,7 +531,7 @@ bool CppCompiler::compileFile(IThreadPool * pool, const char * filename, const c
 
     Owned<CCompilerThreadParam> parm;
     if (verbose)
-        PrintLog("%s", expanded.str());
+        DBGLOG("%s", expanded.str());
     parm.setown(new CCompilerThreadParam(expanded, finishedCompiling, logFile));
     pool->start(parm.get());
 
@@ -709,7 +709,7 @@ bool CppCompiler::doLink()
 
     DWORD runcode = 0;
     if (verbose)
-        PrintLog("%s", expanded.str());
+        UERRLOG("%s", expanded.str());
     StringBuffer logFile = StringBuffer(coreName).append("_link.log.tmp");
     logFiles.append(logFile);
 
@@ -949,11 +949,8 @@ public:
         }
         catch(IException* e)
         {
-            StringBuffer sb;
-            e->errorMessage(sb);
             error.setown(e);
-            if (sb.length())
-                PrintLog("%s", sb.str());
+            EXCLOG(e, "CCompilerWorker::threadmain()");
             success = false;
         }
         handle = 0;

+ 7 - 7
system/jlib/jdebug.cpp

@@ -235,7 +235,7 @@ static void calibrate_timing()
                 return;
             }
         }
-        ERRLOG("calibrate_timing failed using RDTSC");
+        DBGLOG("calibrate_timing failed using RDTSC");
         useRDTSC = false;
     }
 
@@ -348,7 +348,7 @@ void calibrate_timing()
                 return;
             }
         }
-        ERRLOG("calibrate_timing failed using RDTSC");
+        IERRLOG("calibrate_timing failed using RDTSC");
         useRDTSC = false;
     }
 #endif
@@ -571,7 +571,7 @@ public:
         if (numSections())
         {
             StringBuffer str;
-            PrintLog(getTimings(str).str());
+            LOG(MCuserInfo, "%s", getTimings(str).str());
         }
     }
     virtual void mergeTiming(const char * scope, cycle_t totalcycles, cycle_t maxcycles, const unsigned count)
@@ -1417,7 +1417,7 @@ void getDiskUsage(char const * path, unsigned __int64 & total, unsigned __int64
     struct statfs stfs;
     if(statfs(path, &stfs) < 0)
     {
-        //PrintLog("statfs error for filesystem '%s'", path);
+        //IERRLOG("statfs error for filesystem '%s'", path);
         total = inUse = 0;
     }
     else
@@ -1425,7 +1425,7 @@ void getDiskUsage(char const * path, unsigned __int64 & total, unsigned __int64
         struct stat st;
         if(stat(path, &st) < 0)
         {
-            //PrintLog("stat error for filesystem '%s'", path);
+            //IERRLOG("stat error for filesystem '%s'", path);
             total = inUse = 0;
         }
         else
@@ -2189,7 +2189,7 @@ class CExtendedStats  // Disk network and cpu stats
             {
                 if (kbadcnt < 5)
                 {
-                    ERRLOG("klogctl SYSLOG_ACTION_READ_ALL error %d", errno);
+                    IERRLOG("klogctl SYSLOG_ACTION_READ_ALL error %d", errno);
                     kbadcnt++;
                 }
                 else
@@ -3223,7 +3223,7 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe
                 else if (strcmp(perms,"r--p")==0)
                         t = segtype_const;
                 else {
-                    ERRLOG("%s - unknown perms",perms);
+                    IERRLOG("%s - unknown perms",perms);
                     continue;
                 }
                 recs[t].n++;

+ 27 - 27
system/jlib/jexcept.cpp

@@ -631,7 +631,7 @@ void raiseAssertException(const char *assertion, const char *file, unsigned line
     if (queryLogMsgManager())
     {
         printStackReport();
-        ERRLOG("%s",s.str());       // make sure doesn't get lost!
+        IERRLOG("%s",s.str());       // make sure doesn't get lost!
         queryLogMsgManager()->flushQueue(10*1000);
 #ifdef _DEBUG
         // cause a breakpoint in the debugger if we are debugging.
@@ -663,7 +663,7 @@ void raiseAssertCore(const char *assertion, const char *file, unsigned line)
     s.append(sanitizeSourceFile(file));
     s.append(", line ");
     s.append(line);
-    ERRLOG("%s",s.str());       // make sure doesn't get lost!
+    IERRLOG("%s",s.str());       // make sure doesn't get lost!
     queryLogMsgManager()->flushQueue(10*1000);
 #ifdef _WIN32
     userBreakpoint();
@@ -791,7 +791,7 @@ static void ModuleWalk()
     if (!getModuleInformation) 
         return;
     DWORD processID = GetCurrentProcessId();
-    PrintLog( "Process ID: %u", processID );
+    DBGLOG("Process ID: %u", processID);
     
     // Get a list of all the modules in this process.
     
@@ -813,7 +813,7 @@ static void ModuleWalk()
             memset(&modinfo,0,sizeof(modinfo));
             getModuleInformation(hProcess, hMods[i], &modinfo, sizeof(modinfo));
             GetModuleFileName( hMods[i], szModName, sizeof(szModName));
-            PrintLog("%8X %8X %8X  %s",(unsigned)modinfo.lpBaseOfDll,(unsigned)modinfo.SizeOfImage,(unsigned)modinfo.EntryPoint,szModName);
+            IERRLOG("%8X %8X %8X  %s",(unsigned)modinfo.lpBaseOfDll,(unsigned)modinfo.SizeOfImage,(unsigned)modinfo.EntryPoint,szModName);
         }
     }
     
@@ -824,9 +824,9 @@ static void ModuleWalk()
 
 static void StackWalk( size_t pc, size_t bp )
 {
-    PrintLog( "Call stack:" );
+    IERRLOG( "Call stack:" );
     
-    PrintLog( "Address   Frame     Logical addr  Module" );
+    IERRLOG( "Address   Frame     Logical addr  Module" );
     
     size_t * pFrame;
     size_t * pPrevFrame=NULL;
@@ -843,7 +843,7 @@ static void StackWalk( size_t pc, size_t bp )
         else
             strcpy(szModule,"NULL");
         
-        PrintLog( "%08X  %08X  %04X:%08X %s",
+        IERRLOG( "%08X  %08X  %04X:%08X %s",
             pc, pFrame, section, offset, szModule );
         
         if ( (size_t)pFrame & 0x80000003 )    
@@ -877,7 +877,7 @@ static void doPrintStackReport( size_t ip, size_t _bp, size_t sp )
             mov _bp,eax
         }
 #else
-        PrintLog("inline assembler is only supported for x86_32; StackReport incomplete bp tend to not be used");
+        IERRLOG("inline assembler is only supported for x86_32; StackReport incomplete bp tend to not be used");
 #endif
     }
     
@@ -899,14 +899,14 @@ static void doPrintStackReport( size_t ip, size_t _bp, size_t sp )
             s.appendf(" %08X",v);
 #endif
         }
-        PrintLog( "%s",s.str());
+        IERRLOG( "%s",s.str());
     }
     
     
     StackWalk( ip , _bp);
     ModuleWalk();
     StringBuffer threadlist;
-    PrintLog( "ThreadList:\n%s",getThreadList(threadlist).str());
+    IERRLOG( "ThreadList:\n%s",getThreadList(threadlist).str());
     
 }
 
@@ -914,17 +914,17 @@ static void doPrintStackReport( size_t ip, size_t _bp, size_t sp )
 
 static void PrintExceptionReport( PEXCEPTION_POINTERS pExceptionInfo)
 {
-    PrintLog("=====================================================");
+    IERRLOG("=====================================================");
     
     
     PrintMemoryStatusLog();
     PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
     
-    PrintLog(   "Exception code: %08X %s",
+    IERRLOG(   "Exception code: %08X %s",
         pExceptionRecord->ExceptionCode,
         GetExceptionString(pExceptionRecord->ExceptionCode) );
     
-    PrintLog( "Fault address:  %08X", pExceptionRecord->ExceptionAddress);
+    IERRLOG( "Fault address:  %08X", pExceptionRecord->ExceptionAddress);
     
     TCHAR szFaultingModule[MAX_PATH];
     DWORD section, offset;
@@ -933,45 +933,45 @@ static void PrintExceptionReport( PEXCEPTION_POINTERS pExceptionInfo)
         sizeof( szFaultingModule ),
         section, offset );
     
-    PrintLog("Fault module:  %02X:%08X %s", section, offset, szFaultingModule);
+    IERRLOG("Fault module:  %02X:%08X %s", section, offset, szFaultingModule);
     
     PCONTEXT pCtx = pExceptionInfo->ContextRecord;
     
-    PrintLog( "\nRegisters:" );
+    IERRLOG( "\nRegisters:" );
     
 #ifdef _ARCH_X86_64_
-    PrintLog("RAX:%016" I64F "X  RBX:%016" I64F "X  RCX:%016" I64F "X  RDX:%016" I64F "X  RSI:%016" I64F "X  RDI:%016" I64F "X",
+    IERRLOG("RAX:%016" I64F "X  RBX:%016" I64F "X  RCX:%016" I64F "X  RDX:%016" I64F "X  RSI:%016" I64F "X  RDI:%016" I64F "X",
         pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx, pCtx->Rsi, pCtx->Rdi );
-    PrintLog("R8: %016" I64F "X  R9: %016" I64F "X  R10:%016" I64F "X  R11:%016" I64F "X  R12:%016" I64F "X  R13:%016" I64F "X",
+    IERRLOG("R8: %016" I64F "X  R9: %016" I64F "X  R10:%016" I64F "X  R11:%016" I64F "X  R12:%016" I64F "X  R13:%016" I64F "X",
         pCtx->R8, pCtx->R9, pCtx->R10, pCtx->R11, pCtx->R12, pCtx->R13);
-    PrintLog("R14:%016" I64F "X  R15:%016" I64F "X",
+    IERRLOG("R14:%016" I64F "X  R15:%016" I64F "X",
         pCtx->R14, pCtx->R15);
 
-    PrintLog( "CS:RIP:%04X:%016" I64F "X", pCtx->SegCs, pCtx->Rip );
-    PrintLog( "SS:PSP:%04X:%016" I64F "X  PBP:%016" I64F "X",
+    IERRLOG( "CS:RIP:%04X:%016" I64F "X", pCtx->SegCs, pCtx->Rip );
+    IERRLOG( "SS:PSP:%04X:%016" I64F "X  PBP:%016" I64F "X",
         pCtx->SegSs, pCtx->Rsp, pCtx->Rbp );
 #elif defined(_ARCH_X86_)
-    PrintLog("EAX:%08X  EBX:%08X  ECX:%08X  EDX:%08X  ESI:%08X  EDI:%08X",
+    IERRLOG("EAX:%08X  EBX:%08X  ECX:%08X  EDX:%08X  ESI:%08X  EDI:%08X",
         pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx, pCtx->Esi, pCtx->Edi );
     
-    PrintLog( "CS:EIP:%04X:%08X", pCtx->SegCs, pCtx->Eip );
-    PrintLog( "SS:ESP:%04X:%08X  EBP:%08X",
+    IERRLOG( "CS:EIP:%04X:%08X", pCtx->SegCs, pCtx->Eip );
+    IERRLOG( "SS:ESP:%04X:%08X  EBP:%08X",
         pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
 #else
     // ARMFIX: Implement register bank dump for ARM on _WIN32.
-    PrintLog("Register bank not implemented for your platform");
+    IERRLOG("Register bank not implemented for your platform");
 #endif
     
-    PrintLog( "DS:%04X  ES:%04X  FS:%04X  GS:%04X",
+    IERRLOG( "DS:%04X  ES:%04X  FS:%04X  GS:%04X",
         pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
-    PrintLog( "Flags:%08X", pCtx->EFlags );
+    IERRLOG( "Flags:%08X", pCtx->EFlags );
 #ifdef _ARCH_X86_64_
     doPrintStackReport(pCtx->Rip, pCtx->Rbp,pCtx->Rsp);
 #elif defined(_ARCH_X86_)
     doPrintStackReport(pCtx->Eip, pCtx->Ebp,pCtx->Esp);
 #else
     // ARMFIX: Implement stack dump for ARM on _WIN32.
-    PrintLog("Stack report not implemented for your platform");
+    IERRLOG("Stack report not implemented for your platform");
 #endif
     if (SEHtermOnSystemDLLs || SEHtermAlways) {
         char *s = szFaultingModule;

+ 12 - 12
system/jlib/jfile.cpp

@@ -565,7 +565,7 @@ static bool setShareLock(int fd,IFSHmode share)
             return true;
     } while (errno==EINTR);
     if ((errno!=EAGAIN)&&(errno!=EACCES))
-        ERRLOG("setShareLock failure %d, mode %d", errno,(int)share);
+        IERRLOG("setShareLock failure %d, mode %d", errno,(int)share);
     return (share==IFSHfull); // always return true for full
 }
 
@@ -751,7 +751,7 @@ void CFile::rename(const char *newname)
     const char *tail = splitDirTail(newname,newdir);
     if (path.length()&&newdir.length()) {
         if (strcmp(newdir.str(),path.str())!=0) 
-            WARNLOG("CFile::rename '%s' to '%s' : directory mismatch",filename.get(),newname);
+            IWARNLOG("CFile::rename '%s' to '%s' : directory mismatch",filename.get(),newname);
     }
     const char *dst = path.append(tail);
     if (isPathSepChar(dst[0])&&(dst[1]==dst[0])) { // hmm is share - convert to local path
@@ -1270,7 +1270,7 @@ static bool connectToExternalDrive(const char * const filename)
                 err = WNetAddConnection2(&res, password.str(), username.str(), 0);
             }
             if (err) 
-                ERRLOG("WNetAddConnection2(%d): connecting to %s, User: %s",err,res.lpRemoteName,username.str());
+                IERRLOG("WNetAddConnection2(%d): connecting to %s, User: %s",err,res.lpRemoteName,username.str());
         }
         if (err==0)
             return true;
@@ -1404,7 +1404,7 @@ public:
         if ((newname[0]=='\\')&&(newname[1]=='\\')) { // rename to remote
             if (path.length()&&newdir.length()) {
                 if (strcmp(newdir.str(),path.str())!=0) 
-                    WARNLOG("CWindowsRemoteFile '%s' to '%s' : directory mismatch",filename.get(),newname);
+                    IWARNLOG("CWindowsRemoteFile '%s' to '%s' : directory mismatch",filename.get(),newname);
             }
             newname = tail; // just rename using tail
         }
@@ -1717,7 +1717,7 @@ public:
         if (ret==(size32_t)-1)
         {
             PrintStackReport();
-            ERRLOG("errno(%d): %" I64F "d %u",errno,pos,len);
+            IERRLOG("errno(%d): %" I64F "d %u",errno,pos,len);
             throw makeErrnoException(errno, "CFileIO::write");
         }
         if (ret<len)
@@ -3191,7 +3191,7 @@ StringBuffer &createUNCFilename(const char * filename, StringBuffer &UNC, bool u
         if (*filename != '/')
         {
             if (!GetCurrentDirectory(sizeof(buf), buf)) {
-                ERRLOG("createUNCFilename: Current directory path too big, bailing out");
+                IERRLOG("createUNCFilename: Current directory path too big, bailing out");
                 throwUnexpected();
             }
             UNC.append(buf).append("/");
@@ -4577,7 +4577,7 @@ void RemoteFilename::setPath(const SocketEndpoint & _ep, const char * _filename)
         if (isLocal()&&!isAbsolutePath(filename)) {
             char dir[_MAX_PATH];
             if (!GetCurrentDirectory(sizeof(dir), dir)) {
-                ERRLOG("RemoteFilename::setPath: Current directory path too big, bailing out");
+                IERRLOG("RemoteFilename::setPath: Current directory path too big, bailing out");
                 throwUnexpected();
             }
             if (*filename==PATHSEPCHAR) {
@@ -5754,7 +5754,7 @@ private:
                 if (rd!=tord) {
                     eoinput = true;
                     PrintStackReport();
-                    ERRLOG("CFileSerialStream::get read past end of stream.1 (%u,%u) %s",rd,tord,eoinput?"eoinput":"");
+                    IERRLOG("CFileSerialStream::get read past end of stream.1 (%u,%u) %s",rd,tord,eoinput?"eoinput":"");
                     throw MakeStringException(-1,"CFileSerialStream::get read past end of stream");
                 }
                 len -= rd;
@@ -5770,7 +5770,7 @@ private:
             }
         }
         PrintStackReport();
-        ERRLOG("CFileSerialStream::get read past end of stream.2 (%u,%u) %s",len,rd,eoinput?"eoinput":"");
+        IERRLOG("CFileSerialStream::get read past end of stream.2 (%u,%u) %s",len,rd,eoinput?"eoinput":"");
         throw MakeStringException(-1,"CFileSerialStream::get read past end of stream");
     }
 
@@ -6080,7 +6080,7 @@ public:
         memsize_t left = mmsize-mmofs;
         if (len>left) {
             PrintStackReport();
-            ERRLOG("CFileSerialStream::get read past end of stream.3 (%u,%u)",(unsigned)len,(unsigned)left);
+            IERRLOG("CFileSerialStream::get read past end of stream.3 (%u,%u)",(unsigned)len,(unsigned)left);
             throw MakeStringException(-1,"CMemoryMappedSerialStream::get read past end of stream (%u,%u)",(unsigned)len,(unsigned)left);
         }
         if (tally)
@@ -6142,7 +6142,7 @@ public:
     virtual void get(size32_t len, void * ptr) override
     {
         if (len>buffer.remaining()) {
-            ERRLOG("CMemoryBufferSerialStream::get read past end of stream.4(%u,%u)",(unsigned)len,(unsigned)buffer.remaining());
+            IERRLOG("CMemoryBufferSerialStream::get read past end of stream.4(%u,%u)",(unsigned)len,(unsigned)buffer.remaining());
             throw MakeStringException(-1,"CMemoryBufferSerialStream::get read past end of stream (%u,%u)",(unsigned)len,(unsigned)buffer.remaining());
         }
         const void * data = buffer.readDirect(len);
@@ -6457,7 +6457,7 @@ size32_t SendFile(ISocket *target, IFileIO *fileio,offset_t start,size32_t len)
 
 #ifdef _DEBUG
 #ifndef _WIN32
-    WARNLOG("SendFile falling back");
+    IWARNLOG("SendFile falling back");
 #endif
 #endif
 

+ 3 - 3
system/jlib/jio.cpp

@@ -803,7 +803,7 @@ ElevatorScanner::ElevatorScanner(int _file, size32_t _recordSize) : Thread("Elev
 
 ElevatorScanner::~ElevatorScanner()
 {
-    PrintLog("Elevator scanner statistics: %" I64F "d reads (%" I64F "d bytes), %d scans", reads, reads*recordSize, scans);
+    IERRLOG("Elevator scanner statistics: %" I64F "d reads (%" I64F "d bytes), %d scans", reads, reads*recordSize, scans);
 }
 
 void ElevatorScanner::beforeDispose()
@@ -858,7 +858,7 @@ void ElevatorScanner::doFetch(PendingFetch &next)
 
 void ElevatorScanner::scan()
 {
-    PrintLog("Starting elevator scan of %d items", nextSlot);
+    DBGLOG("Starting elevator scan of %d items", nextSlot);
     scans++;
     qsort(pending, nextSlot, sizeof(pending[0]), PendingFetch::compare);
     for (unsigned i = 0; i < nextSlot; i++)
@@ -870,7 +870,7 @@ void ElevatorScanner::scan()
         synchronized block(isRoom);
         isRoom.notify();
     }
-    PrintLog("Finished elevator scan");
+    DBGLOG("Finished elevator scan");
 }
 
 void ElevatorScanner::flush(IRecordFetchChannel *)

+ 4 - 4
system/jlib/jlog.cpp

@@ -851,7 +851,7 @@ FileLogMsgHandler::FileLogMsgHandler(const char * _filename, const char * _heade
         handle = getNullHandle();
         StringBuffer err;
         err.appendf("LOGGING: could not open file '%s' for output",filename.get());
-        ERRLOG("%s",err.str()); // make sure doesn't get lost!
+        OERRLOG("%s",err.str()); // make sure doesn't get lost!
         throw MakeStringException(3000,"%s",err.str()); // 3000: internal error
     }
     if(headerText) fprintf(handle, "--- %s ---\n", (const char *)headerText);
@@ -1024,7 +1024,7 @@ void RollingFileLogMsgHandler::doRollover(bool daily, const char *forceName) con
     if(!handle) 
     {
         handle = getNullHandle();
-        DBGLOG("RollingFileLogMsgHandler::doRollover : could not open log file %s for output", filename.str());
+        OWARNLOG("RollingFileLogMsgHandler::doRollover : could not open log file %s for output", filename.str());
         // actually this is pretty fatal
     }
 }
@@ -2338,7 +2338,7 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
         }
         hEventLog = RegisterEventSource(NULL,"Seisint");
         if (!hEventLog) {
-            ERRLOG("reportEventLog: Could not register Seisint event source");
+            OERRLOG("reportEventLog: Could not register Seisint event source");
             hEventLog=(HANDLE)-1;
             return false;
         }
@@ -2781,7 +2781,7 @@ public:
             if (!logDir.length())
             {
                 appendCurrentDirectory(logDir,false).append(PATHSEPSTR).append("logs");
-                WARNLOG("No logfile directory specified - logs will be written locally to %s", logDir.str());
+                OWARNLOG("No logfile directory specified - logs will be written locally to %s", logDir.str());
             }
 
             makeAbsolutePath(logDir);

+ 171 - 64
system/jlib/jlog.hpp

@@ -35,6 +35,82 @@
 #include "jptree.hpp"
 #include "jsocket.hpp"
 
+/****************************************************************************************/
+/* LOG MESSAGE AUDIENCES:                                                               *
+ * MSGAUD_operator - This should be used when the message may be normally monitored by, *
+ *                   acted on, or resolved by sys admins. E.g. out of memory alerts,    *
+ *                   configuration issues, possible hardware/network related issues,    *
+ * MSGAUD_user     - Messages targetted at the end-users of HPCC (including ecl coders  *
+ *                   E.g. ECL code issues, workunit issues, data file related issues,   *
+ *                   authentication issues                                              *
+ * MSGAUD_programmer - Messages targetted at platform developers. E.g. debugging        *
+ *                   and tracing messages, internal errors that would not normally be   *
+ *                   resolved by sys admins or users, unexpected internal error         *
+ * MSGAUD_audit    - Audit messages related to file access and authentication           *
+ * ------------------------------------------------------------------------------------ *
+ * LOG MESSAGE CLASS:                                                                   */
+typedef enum
+{
+    MSGCLS_disaster    = 0x01, // Any unrecoverable or critical system errors
+    MSGCLS_error       = 0x02, // Recoverable/not critical Errors
+    MSGCLS_warning     = 0x04, // Warnings
+    MSGCLS_information = 0x08, // Config, environmental and internal status  info
+    MSGCLS_progress    = 0x10, // Progress of workunits. Status of file operations
+    MSGCLS_legacy      = 0x20, // Depreciated, TODO: remove
+    MSGCLS_all         = 0xFF  // Use as a filter to select all messages
+} LogMsgClass;
+/* ------------------------------------------------------------------------------------ *
+ * NOTES:                                                                               *
+ * Every message will have an audience and message class. The job number is optional    *
+ *                                                                                      *
+ * Standard categories of Audience + Message class are defined with LogMsgCategory.     *
+ *                                                                                      *
+ * The following are common logging functions (for common audience+message class)       *
+ * 1) For temporary logs whilst debugging (may be disabled for releases ):              *
+ *    DBGLOG([LogMsgCode,] format,..)          - uses MCdebugInfo                       *
+ *                                                                                      *
+ * 2) For fatal errors or unrecoverable errors:                                         *
+ *    DISLOG([LogMsgCode,] format,..)          - uses MCdisaster                        *
+ *                                                                                      *
+ * 3) For warning messages:                                                             *
+ *    (i) Messages for End-users (including ECL coders) should use:                     *
+ *        UWARNLOG([LogMsgCode,] format,..)    - uses MCuserWarning                     *
+ *                                                                                      *
+ *    (ii) Messages for SysAdmins:                                                      *
+ *        OWARNLOG([LogMsgCode,] format,..)    - uses MCoperatorWarning                 *
+ *                                                                                      *
+ *    (iii) Messages for platform developers:                                           *
+ *        IWARNLOG([LogMsgCode,] format,..)    - uses MCinternalWarning                 *
+ *                                                                                      *
+ * 4) For error messages:                                                               *
+ *    (i) Messages for End-users (including ECL coders) should use:                     *
+ *        UERRLOG([LogMsgCode,] format,..)     - uses MCuserError                       *
+ *                                                                                      *
+ *    (ii) Messages for SysAdmins:                                                      *
+ *        OERRLOG([LogMsgCode,] format,..)     - uses MCoperatorError                   *
+ *                                                                                      *
+ *    (iii) Messages for platform developers:                                           *
+ *        IERRLOG([LogMsgCode,] format,..)     - uses MCinternalError                   *
+ *                                                                                      *
+ *    (iv) Messages for audit:                                                          *
+ *        AERRLOG([LogMsgCode,] format,..)     - uses MCinternalError                   *
+ *                                                                                      *
+ *                                                                                      *
+ * 5) For progress messages:                                                            *
+ *    PROGLOG([LogMsgCode,] format,..)         - uses MCuserProgress                    *
+ *                                                                                      *
+ * More general logging functions include:                                              *
+ * 1) Full control over the log message:                                                *
+ *   LOG(LogMsgCategory, [job,] [code,] format, ...)                                    *
+ * 2) Takes code, message, & audience from an exception, class is error                 *
+ *    EXCLOG(exception, prefix)                                                         *
+ * 3) More control over logging exceptions:                                             *
+ *    LOG(LogMsgCategory, [job,] exception [, prefix])                                  *
+ *                                                                                      *
+ * LogMsgCategory detail level may be modified from the default with a numeric paramter *
+ * For example as MCdebugInfo(50).                                                      *
+ ****************************************************************************************/
+
 
 // ENUMS, TYPEDEFS, CONSTS ETC.
 
@@ -44,8 +120,6 @@
 
 typedef MessageAudience LogMsgAudience;
 
-#define MSGAUDNUM 8
-
 inline const char * LogMsgAudienceToVarString(LogMsgAudience audience)
 {
     switch(audience)
@@ -84,21 +158,6 @@ inline const char * LogMsgAudienceToFixString(LogMsgAudience audience)
     }
 }
 
-// When changing this enum, be sure to update (a) the string functions, and (b) NUM value
-
-typedef enum
-{
-    MSGCLS_disaster    = 0x01, /* Any unrecoverable or critical system errors */
-    MSGCLS_error       = 0x02, /* Recoverable/not critical Errors */
-    MSGCLS_warning     = 0x04, /* Warnings */
-    MSGCLS_information = 0x08, /* Config, environmental and internal status  info */
-    MSGCLS_progress    = 0x10, /* Progress of workunits. Status of file operations*/
-    MSGCLS_legacy      = 0x20, /* TODO: to be removed */
-    MSGCLS_all         = 0xFF  /* Use as a filter to select all messages */
-} LogMsgClass;
-
-#define MSGCLSNUM 7
-
 inline const char * LogMsgClassToVarString(LogMsgClass msgClass)
 {
     switch(msgClass)
@@ -669,12 +728,14 @@ constexpr LogMsgCategory MCdisaster(MSGAUD_all, MSGCLS_disaster);
 constexpr LogMsgCategory MCuserError(MSGAUD_user, MSGCLS_error);
 constexpr LogMsgCategory MCoperatorError(MSGAUD_operator, MSGCLS_error);
 constexpr LogMsgCategory MCinternalError(MSGAUD_programmer, MSGCLS_error, 1);
+constexpr LogMsgCategory MCauditError(MSGAUD_audit, MSGCLS_error);
 constexpr LogMsgCategory MCuserWarning(MSGAUD_user, MSGCLS_warning);
 constexpr LogMsgCategory MCoperatorWarning(MSGAUD_operator, MSGCLS_warning);
 constexpr LogMsgCategory MCinternalWarning(MSGAUD_programmer, MSGCLS_warning, 1);
 constexpr LogMsgCategory MCuserProgress(MSGAUD_user, MSGCLS_progress);
 constexpr LogMsgCategory MCoperatorProgress(MSGAUD_operator, MSGCLS_progress);
 constexpr LogMsgCategory MCdebugProgress(MSGAUD_programmer, MSGCLS_progress);
+constexpr LogMsgCategory MCuserInfo(MSGAUD_user, MSGCLS_information);
 constexpr LogMsgCategory MCdebugInfo(MSGAUD_programmer, MSGCLS_information);
 constexpr LogMsgCategory MCstats(MSGAUD_operator, MSGCLS_progress);
 constexpr LogMsgCategory MCoperatorInfo(MSGAUD_operator, MSGCLS_information);
@@ -803,8 +864,8 @@ inline void DISLOG(char const * format, ...)
     va_end(args);
 }
 
-inline void ERRLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
-inline void ERRLOG(char const * format, ...) 
+inline void UERRLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
+inline void UERRLOG(char const * format, ...)
 {
     va_list args;
     va_start(args, format);
@@ -812,6 +873,9 @@ inline void ERRLOG(char const * format, ...)
     va_end(args);
 }
 
+// TODO: Remove the following #define once all ERRLOG has been removed from code
+#define ERRLOG UERRLOG
+
 inline void OERRLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
 inline void OERRLOG(char const * format, ...)
 {
@@ -830,8 +894,18 @@ inline void IERRLOG(char const * format, ...)
     va_end(args);
 }
 
-inline void WARNLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
-inline void WARNLOG(char const * format, ...)
+inline void AERRLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
+inline void AERRLOG(char const * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCauditError, unknownJob, format, args);
+    va_end(args);
+}
+
+
+inline void UWARNLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
+inline void UWARNLOG(char const * format, ...)
 {
     va_list args;
     va_start(args, format);
@@ -839,12 +913,33 @@ inline void WARNLOG(char const * format, ...)
     va_end(args);
 }
 
-inline void PROGLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
-inline void PROGLOG(char const * format, ...)
+// TODO: Remove the following #define once all WARNLOG has been removed from code
+#define WARNLOG UWARNLOG
+
+inline void OWARNLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
+inline void OWARNLOG(char const * format, ...)
 {
     va_list args;
     va_start(args, format);
-    VALOG(MCprogress, unknownJob, format, args);
+    VALOG(MCoperatorWarning, unknownJob, format, args);
+    va_end(args);
+}
+
+inline void IWARNLOG(char const * format, ...) __attribute__((format(printf, 1, 2)));
+inline void IWARNLOG(char const * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCinternalWarning, unknownJob, format, args);
+    va_end(args);
+}
+
+inline void PROGLOG(const char * format, ...) __attribute__((format(printf, 1, 2)));
+inline void PROGLOG(const char * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCuserProgress, unknownJob, format, args);
     va_end(args);
 }
 
@@ -866,12 +961,39 @@ inline void DISLOG(LogMsgCode code, char const * format, ...)
     va_end(args);
 }
 
-inline void ERRLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
-inline void ERRLOG(LogMsgCode code, char const * format, ...)
+inline void UWARNLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
+inline void UWARNLOG(LogMsgCode code, char const * format, ...)
 {
     va_list args;
     va_start(args, format);
-    VALOG(MCuserError, unknownJob, code, format, args);
+    VALOG(MCuserWarning, unknownJob, code, format, args);
+    va_end(args);
+}
+
+inline void OWARNLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
+inline void OWARNLOG(LogMsgCode code, char const * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCoperatorWarning, unknownJob, code, format, args);
+    va_end(args);
+}
+
+inline void IWARNLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
+inline void IWARNLOG(LogMsgCode code, char const * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCinternalWarning, unknownJob, code, format, args);
+    va_end(args);
+}
+
+inline void OERRLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
+inline void OERRLOG(LogMsgCode code, char const * format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    VALOG(MCoperatorError, unknownJob, code, format, args);
     va_end(args);
 }
 
@@ -884,12 +1006,12 @@ inline void IERRLOG(LogMsgCode code, char const * format, ...)
     va_end(args);
 }
 
-inline void WARNLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
-inline void WARNLOG(LogMsgCode code, char const * format, ...)
+inline void UERRLOG(LogMsgCode code, char const * format, ...) __attribute__((format(printf, 2, 3)));
+inline void UERRLOG(LogMsgCode code, char const * format, ...)
 {
     va_list args;
     va_start(args, format);
-    VALOG(MCuserWarning, unknownJob, code, format, args);
+    VALOG(MCuserError, unknownJob, code, format, args);
     va_end(args);
 }
 
@@ -898,7 +1020,7 @@ inline void PROGLOG(LogMsgCode code, char const * format, ...)
 {
     va_list args;
     va_start(args, format);
-    VALOG(MCprogress, unknownJob, code, format, args);
+    VALOG(MCuserProgress, unknownJob, code, format, args);
     va_end(args);
 }
 
@@ -908,6 +1030,24 @@ inline IException *DBGLOG(IException *except, const char *prefix=NULL)
     return except;
 }
 
+inline IException *IERRLOG(IException *except, const char *prefix=NULL)
+{
+    LOG(MCinternalError, except, prefix);
+    return except;
+}
+
+inline IException *UERRLOG(IException *except, const char *prefix=NULL)
+{
+    LOG(MCuserError, except, prefix);
+    return except;
+}
+
+inline IException *OERRLOG(IException *except, const char *prefix=NULL)
+{
+    LOG(MCoperatorError, except, prefix);
+    return except;
+}
+
 inline IException *DISLOG(IException *except, const char *prefix=NULL)
 {
     LOG(MCdisaster, except, prefix);
@@ -948,39 +1088,6 @@ extern jlib_decl void UseSysLogForOperatorMessages(bool use=true);
 
 extern jlib_decl void AuditSystemAccess(const char *userid, bool success, char const * msg,...) __attribute__((format(printf, 3, 4)));
 
-/***************************************************************************/
-/* The simplest logging commands are:                                      */
-/*   DBGLOG(format, ...) [for temporary logs while debugging, MCdebugInfo] */
-/*   DISLOG(format, ...) [for disasters, MCdisaster]                       */
-/*   ERRLOG(format, ...) [for errors reported to user, MCuserError]        */
-/*   OERRLOG(format, ...) [for errors reported to operator]                */
-/*   IERRLOG(format, ...) [for errors reported to internal & programmer]   */
-/*   WARNLOG(format, ...) [for warnings reported to user, MCuserWarning]   */
-/*   PROGLOG(format, ...) [for progress logs to user, MCprogress]          */
-/* There are equivalent commands which take a LogMsgCode:                  */
-/*   DBGLOG(code, format, ...)                                             */
-/*   DISLOG(code, format, ...)                                             */
-/*   ERRLOG(code, format, ...)                                             */
-/*   OERRLOG(code, format, ...)                                            */
-/*   IERRLOG(code, format, ...)                                            */
-/*   WARNLOG(code, format, ...)                                            */
-/*   PROGLOG(code, format, ...)                                            */
-/* This takes code, message, & audience from an exception, class is error  */
-/*   EXCLOG(exception, prefix)                                             */
-/* The more general logging command has the following forms:               */
-/*   LOG(category, format, ...)                                            */
-/*   LOG(category, code, format, ...)                                      */
-/*   LOG(category, job, format, ...)                                       */
-/*   LOG(category, job, code, format, ...)                                 */
-/* In the first and second cases, the common unknownJob is used.           */
-/* There are also forms to log exceptions:                                 */
-/*   LOG(category, exception)                                              */
-/*   LOG(category, exception, prefix)                                      */
-/*   LOG(category, job, exception)                                         */
-/*   LOG(category, job, exception, prefix)                                 */
-/* The off-the-shelf categories, MCdebugInfo et al, are listed above.      */
-/* Their detail level can be modified from the default as MCdebugInfo(50). */
-/***************************************************************************/
 
 interface jlib_decl IContextLogger : extends IInterface
 {

+ 15 - 15
system/jlib/jmisc.cpp

@@ -219,12 +219,12 @@ jlib_decl void openLogFile(StringBuffer & resolvedFS, const char *filename, unsi
     resolvedFS.set(lf->queryLogFileSpec());
 }
 
-jlib_decl void PrintLogDirect(const char *msg)
+jlib_decl void PrintLogDirect(const char *msg)  // Legacy TODO: remove
 {
     LOG(MClegacy, unknownJob, "%s", msg);
 }
 
-jlib_decl int PrintLog(const char *fmt, ...)
+jlib_decl int PrintLog(const char *fmt, ...)  // Legacy TODO: remove
 {
     va_list args;
     va_start(args, fmt);
@@ -233,7 +233,7 @@ jlib_decl int PrintLog(const char *fmt, ...)
     return 0;
 }
 
-jlib_decl void SPrintLog(const char *fmt, ...)
+jlib_decl void SPrintLog(const char *fmt, ...)  // Legacy TODO: remove
 {
     va_list args;
     va_start(args, fmt);
@@ -430,7 +430,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
         outh = CreateFile(outfile,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,&security,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
         if (outh == INVALID_HANDLE_VALUE)
         {
-            ERRLOG("Cannot create file '%s' error code %d",outfile,(int)GetLastError());
+            OERRLOG("Cannot create file '%s' error code %d",outfile,(int)GetLastError());
             return false;
         }
     }
@@ -438,7 +438,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
         if (!DuplicateHandle(GetCurrentProcess(),outh,GetCurrentProcess(),&StartupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS) || 
              !DuplicateHandle(GetCurrentProcess(),outh,GetCurrentProcess(),&StartupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS))
         {
-            ERRLOG("Execution of \"%s\" failed, DuplicateHandle error = %d",command_line, (int)GetLastError());
+            OERRLOG("Execution of \"%s\" failed, DuplicateHandle error = %d",command_line, (int)GetLastError());
             CloseHandle(outh);
             return false;
         }
@@ -468,7 +468,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
     {
         int lastError = (int)GetLastError();      // for debugging
         //print out why create process failed
-        ERRLOG("Execution of \"%s\" failed, error = %d",command_line,lastError);
+        OERRLOG("Execution of \"%s\" failed, error = %d",command_line,lastError);
     }
     if (outh)
     {
@@ -498,7 +498,7 @@ jlib_decl bool interrupt_program(HANDLE handle, bool stopChildren, int signum)
 {
     if (signum==0)
         return TerminateProcess(handle,1)!=FALSE;
-    ERRLOG("interrupt_program signal %d not supported in windows",signum);
+    OERRLOG("interrupt_program signal %d not supported in windows",signum);
     return false;
 }
 
@@ -532,7 +532,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
                 close(outh);
             }
             else  {
-                ERRLOG("invoke_program: could not open %s",outfile);
+                OERRLOG("invoke_program: could not open %s",outfile);
                 return false;
             }
         }
@@ -564,7 +564,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
         {
             //print out why create process failed
             int err = errno;
-            ERRLOG("invoke_program(%s) failed with error(%d): %s",command_line,err,strerror(err));
+            OERRLOG("invoke_program(%s) failed with error(%d): %s",command_line,err,strerror(err));
         }
         assertex(0); // don't expect to get here!
         _exit(0);
@@ -580,7 +580,7 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
         else
             s.append(errno);
 
-        ERRLOG("%s",s.str());
+        OERRLOG("%s",s.str());
         if(throwException)
             throw MakeStringExceptionDirect(-1, s.str());
         return false;
@@ -598,16 +598,16 @@ bool invoke_program(const char *command_line, DWORD &runcode, bool wait, const c
                 break;
             if (errno != EINTR)
             {
-                ERRLOG("invoke_program(%s): wait failed (%d, %d, %d)",command_line,(int) wpid, retv, errno);
+                OERRLOG("invoke_program(%s): wait failed (%d, %d, %d)",command_line,(int) wpid, retv, errno);
                 return false;
             }
         }
         if (!WIFEXITED(retv)) //did not exit normally
         {
             int err = errno;
-            ERRLOG("invoke_program(%s): failed.",command_line);
-            ERRLOG("The process was killed by signal %d%s.",(int)WTERMSIG(retv),WCOREDUMP(retv)?" - core dumped":"");
-            ERRLOG("Last system error is %s",strerror(err));
+            OERRLOG("invoke_program(%s): failed.",command_line);
+            OERRLOG("The process was killed by signal %d%s.",(int)WTERMSIG(retv),WCOREDUMP(retv)?" - core dumped":"");
+            OERRLOG("Last system error is %s",strerror(err));
         }
 
         runcode = WEXITSTATUS(retv);
@@ -625,7 +625,7 @@ bool wait_program(HANDLE handle,DWORD &runcode,bool block)
     int retv;
     pid_t ret = waitpid(pid, &retv, block?0:WNOHANG);
     if (ret == (pid_t)-1) {
-        ERRLOG("wait_program: wait failed (%d)",errno);
+        IERRLOG("wait_program: wait failed (%d)",errno);
         return true; // actually it failed but assume finished
     }
     else if (ret==0)

+ 1 - 1
system/jlib/jmutex.cpp

@@ -198,7 +198,7 @@ static void unlock_file(const char *lfpath)
         attempt++;
         Sleep(500);
     }
-    ERRLOG("NamedMutex cannot unlock file (%d)",errno);
+    IERRLOG("NamedMutex cannot unlock file (%d)",errno);
 }
 
 static CriticalSection lockPrefixCS;

+ 1 - 1
system/jlib/jpqueue.hpp

@@ -151,7 +151,7 @@ public:
                 workers.push_back(new WorkerThread(*this));
                 workers.back()->start();
             }
-//            PrintLog("%d threads",workers.size());
+//            DBGLOG("%d threads",workers.size());
         }
     }
 

+ 1 - 1
system/jlib/jptree.cpp

@@ -2870,7 +2870,7 @@ bool PTree::checkPattern(const char *&xxpath) const
                     if (legacynumeric)
                     {
                         if (isdigit(*rhs))
-                            WARNLOG("Possible deprecated use of quoted numeric comparison operation: %s", xxpath);
+                            IWARNLOG("Possible deprecated use of quoted numeric comparison operation: %s", xxpath);
                     }
 #endif
                 }

+ 7 - 7
system/jlib/jregexp.cpp

@@ -1726,27 +1726,27 @@ long Cla$MATCH(/* STRING s, STRING p, */ unsigned char flags)
 
 void tr (RegExpr &RE,const char *s,const char *p,const char *r=NULL,size32_t n=0,bool nocase=false)
 {
-  PrintLog("Test '%s','%s','%s',%d,%s\r\n",s,p,r?r:"-",n,nocase?"NOCASE":"");
+  DBGLOG("Test '%s','%s','%s',%d,%s\r\n",s,p,r?r:"-",n,nocase?"NOCASE":"");
   char l[256];
   strcpy(l,s);
   StringBuffer ds;
   RE.init(p,nocase);
   const char * f = RE.find(l,0,RE_ALL);
   if (!f)
-    PrintLog("Not Found\r\n");
+    DBGLOG("Not Found\r\n");
   else {
-    PrintLog("Found '%s'\r\n",RE.findstr(ds));
+    DBGLOG("Found '%s'\r\n",RE.findstr(ds));
     for (int i = 1;i<=9;i++) {
       size32_t s = RE.findlen(i);
       if (s) {
         ds.clear();
-        PrintLog("Found Sub %d,%d,'%s'\r\n",i,s,RE.findstr(ds,i));
+        DBGLOG("Found Sub %d,%d,'%s'\r\n",i,s,RE.findstr(ds,i));
       }
     }
   }
   if (r) {
     RE.replace(r,sizeof(l));
-    PrintLog("Replace to '%s'\r\n",l);
+    DBGLOG("Replace to '%s'\r\n",l);
   }
 }
 
@@ -1813,12 +1813,12 @@ void RE$Test()
   RE.init("^{|{.+}@}{[^@]+}$");
   RE.find(str);
   StringBuffer t;
-  PrintLog("Substitute to '%s'\r\n",RE.substitute(t,"#'#3###2'#"));
+  DBGLOG("Substitute to '%s'\r\n",RE.substitute(t,"#'#3###2'#"));
   t.clear();
   RE.replace(RE.findstr(t,2),sizeof(str),3);
   t.clear();
   RE.replace(RE.findstr(t,3),sizeof(str),2);
-  PrintLog("Replace to '%s'\r\n",str);
+  DBGLOG("Replace to '%s'\r\n",str);
 }
 
 void FixDate(char *buff,size32_t max)

+ 4 - 4
system/jlib/jscm.hpp

@@ -183,8 +183,8 @@ class StringBuffer;
 
 typedef enum
 {
-    // Target audience: sysadmins
-    // Purpose: Information useful for administering the platform, diagnosing errors and 
+    // Target audience: system admins
+    // Purpose: Information useful for administering the platform, diagnosing errors and
     //          resolving system issues
     MSGAUD_operator    = 0x01,
     // Target audience: ECL developers
@@ -194,11 +194,11 @@ typedef enum
     // Target audience: HPCC Platform developers
     // Purpose: Information related to errors relating to potential bugs or any unexpected errors that
     //          would not be resolvable by sysadmin or ECL developers. Additional information that may
-    //          be useful for improving the platform. 
+    //          be useful for improving the platform.
     MSGAUD_programmer  = 0x20,
     // TODO: to be removed
     MSGAUD_legacy      = 0x40,
-    // Target audience: persons involved in accounting and security audits 
+    // Target audience: persons involved in accounting and security audits
     MSGAUD_audit       = 0x80,
     // MSGAUD_all is to be used for filtering or specifying which messages are to be logged
     // (A message itself should not be logged as MSGAUD_all)

+ 15 - 15
system/jlib/jsocket.cpp

@@ -1012,7 +1012,7 @@ ISocket* CSocket::accept(bool allowcancel)
         return NULL;
     }
     if (state != ss_open) {
-        ERRLOG("invalid accept, state = %d",(int)state);
+        IERRLOG("invalid accept, state = %d",(int)state);
         THROWJSOCKEXCEPTION(JSOCKERR_not_opened);
     }
     if (connectionless()) {
@@ -1069,7 +1069,7 @@ void CSocket::set_linger(int lingertime)
     l.l_onoff = (lingertime>=0)?1:0;
     l.l_linger = (lingertime>=0)?lingertime:0;
     if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)) != 0) {
-        WARNLOG("Linger not set");
+        IWARNLOG("Linger not set");
     }
 }
 
@@ -1077,7 +1077,7 @@ void CSocket::set_keep_alive(bool set)
 {
     int on=set?1:0;
     if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&on, sizeof(on)) != 0) {
-        WARNLOG("KeepAlive not set");
+        IWARNLOG("KeepAlive not set");
     }
 }
 
@@ -1362,7 +1362,7 @@ void CSocket::connect_wait(unsigned timems)
                 unsigned sleeptime = getRandom() % 1000;
                 StringBuffer s;
                 ep.getIpText(s);
-                PrintLog("Connection to central node %s - sleeping %d milliseconds", s.str(), sleeptime);
+                DBGLOG("Connection to central node %s - sleeping %d milliseconds", s.str(), sleeptime);
                 Sleep(sleeptime);           
                 break;
             }
@@ -2062,7 +2062,7 @@ size32_t CSocket::writetms(void const* buf, size32_t size, unsigned timeoutms)
 
     if (nwritten < size)
     {
-        ERRLOG("writetms timed out; timeout: %u, nwritten: %u, size: %u", timeoutms, nwritten, size);
+        IERRLOG("writetms timed out; timeout: %u, nwritten: %u, size: %u", timeoutms, nwritten, size);
         THROWJSOCKEXCEPTION(JSOCKERR_timeout_expired);
     }
 
@@ -2335,7 +2335,7 @@ bool CSocket::send_block(const void *blk,size32_t sz)
     }
 #ifdef TRACE_SLOW_BLOCK_TRANSFER
     if (elapsed>1000000*60)  // over 1min
-        WARNLOG("send_block took %ds to %s  (%d,%d,%d)",elapsed/1000000,tracename,startt2-startt,startt3-startt2,nowt-startt3);
+        IWARNLOG("send_block took %ds to %s  (%d,%d,%d)",elapsed/1000000,tracename,startt2-startt,startt3-startt2,nowt-startt3);
 #endif
     return true;
 }
@@ -2397,7 +2397,7 @@ size32_t CSocket::receive_block_size()
 #ifdef USERECVSEM
             CSemProtect semprot; // this will catch exception in write
             while (!semprot.wait(&receiveblocksem,&receiveblocksemowned,60*1000*5))
-                WARNLOG("Receive block stalled");
+                IWARNLOG("Receive block stalled");
 #endif
             bool eof=false;
             write(&eof,sizeof(eof));
@@ -2570,7 +2570,7 @@ void CSocket::set_send_buffer_size(size32_t maxsend)
         LOGERR2(ERRNO(),1,"getsockopt(SO_SNDBUF)");
     }
     if (v!=maxsend) 
-        WARNLOG("set_send_buffer_size requested %d, got %d",maxsend,v);
+        IWARNLOG("set_send_buffer_size requested %d, got %d",maxsend,v);
 #endif
 }
 
@@ -2595,7 +2595,7 @@ void CSocket::set_receive_buffer_size(size32_t max)
         LOGERR2(ERRNO(),1,"getsockopt(SO_RCVBUF)");
     }
     if (v<max) 
-        WARNLOG("set_receive_buffer_size requested %d, got %d",max,v);
+        IWARNLOG("set_receive_buffer_size requested %d, got %d",max,v);
 #endif
 }
 
@@ -2938,7 +2938,7 @@ bool getInterfaceIp(IpAddress &ip,const char *ifname)
             {
                 if (!recursioncheck) {
                     recursioncheck = true;
-                    DBGLOG("Error retrieving interface flags for interface %s", item->ifr_name);
+                    IERRLOG("Error retrieving interface flags for interface %s", item->ifr_name);
                     recursioncheck = false;
                 }
                 continue;
@@ -4069,7 +4069,7 @@ class CSocketSelectThread: public CSocketBaseThread
         if (!dummysockopen) { 
 #ifdef _USE_PIPE_FOR_SELECT_TRIGGER
             if(pipe(dummysock)) {
-                WARNLOG("CSocketSelectThread: create pipe failed %d",ERRNO());
+                IWARNLOG("CSocketSelectThread: create pipe failed %d",ERRNO());
                 return;
             }
             for (unsigned i=0;i<2;i++) {
@@ -4717,7 +4717,7 @@ class CSocketEpollThread: public CSocketBaseThread
         // if another thread closed fd before here don't fail
         if ( (srtn < 0) && (op != EPOLL_CTL_DEL) ){
             int err = ERRNO();
-            WARNLOG("epoll_ctl failed op:%d, fd:%d, err=%d", op, fd, err);
+            IWARNLOG("epoll_ctl failed op:%d, fd:%d, err=%d", op, fd, err);
         }
     }
 
@@ -4734,7 +4734,7 @@ class CSocketEpollThread: public CSocketBaseThread
 #ifdef _USE_PIPE_FOR_SELECT_TRIGGER
             if(pipe(dummysock))
             {
-                WARNLOG("CSocketEpollThread: create pipe failed %d",ERRNO());
+                IWARNLOG("CSocketEpollThread: create pipe failed %d",ERRNO());
                 return;
             }
             for (unsigned i=0;i<2;i++)
@@ -4952,7 +4952,7 @@ public:
         if ( !sock || !nfy ||
              !(mode & (SELECTMODE_READ|SELECTMODE_WRITE|SELECTMODE_EXCEPT)) )
         {
-            WARNLOG("EPOLL: adding fd but sock or nfy is NULL or mode is empty");
+            IWARNLOG("EPOLL: adding fd but sock or nfy is NULL or mode is empty");
             dbgassertex(false);
             return 0;
         }
@@ -5001,7 +5001,7 @@ public:
             if (!checkSocks())
             {
                 // bad socket not found
-                WARNLOG("CSocketEpollThread::updateEpollVars cannot find socket error");
+                IWARNLOG("CSocketEpollThread::updateEpollVars cannot find socket error");
                 if (validateerrcount>10)
                     throw MakeStringException(-1,"CSocketEpollThread:Socket epoll error %d",validateselecterror);
             }

+ 1 - 1
system/jlib/jsort.cpp

@@ -491,7 +491,7 @@ void parqsortvec(void **a, size32_t n, const ICompare & compare, unsigned numcpu
 #ifdef TESTPARSORT
     for (unsigned i=1;i<n;i++)
         if (compare.docompare(a[i-1],a[i])>0)
-            ERRLOG("parqsortvec failed %d",i);
+            IERRLOG("parqsortvec failed %d",i);
 #endif
 
 }

+ 1 - 1
system/jlib/jstring.cpp

@@ -455,7 +455,7 @@ StringBuffer & StringBuffer::limited_valist_appendf(size_t szLimit, const char *
             if (0 != szLimit && size>szLimit) size = szLimit; // if so, will be last attempt
             if (size>MAX_BUF_SIZE)
             {
-                WARNLOG("StringBuffer::valist_appendf(\"%s\"): vsnprintf exceeds limit (%zu)", format, size);
+                IWARNLOG("StringBuffer::valist_appendf(\"%s\"): vsnprintf exceeds limit (%zu)", format, size);
                 size = szLimit = MAX_BUF_SIZE;
             }
             try { ensureCapacity(size); }

+ 14 - 14
system/jlib/jthread.cpp

@@ -334,7 +334,7 @@ void Thread::init(const char *_name)
 void Thread::start()
 {
     if (alive) {
-        WARNLOG("Thread::start(%s) - Thread already started!",getName());
+        IWARNLOG("Thread::start(%s) - Thread already started!",getName());
         PrintStackReport();
 #ifdef _DEBUG
         throw MakeStringException(-1,"Thread::start(%s) - Thread already started!",getName());
@@ -381,7 +381,7 @@ void Thread::startRelease()
         if ((status==EAGAIN)||(status==EINTR)) {
             if (numretrys--==0)
                 break;
-            WARNLOG("pthread_create(%d): Out of threads, retrying...",status);
+            IWARNLOG("pthread_create(%d): Out of threads, retrying...",status);
             Sleep(delay);
             delay *= 2;
         }
@@ -391,12 +391,12 @@ void Thread::startRelease()
     if (status) {
         threadid = 0;
         Release();
-        ERRLOG("pthread_create returns %d",status);
+        IERRLOG("pthread_create returns %d",status);
         PrintStackReport();
         PrintMemoryReport();
         StringBuffer s;
         getThreadList(s);
-        ERRLOG("Running threads:\n %s",s.str());
+        IERRLOG("Running threads:\n %s",s.str());
         throw makeOsException(status);
     }
     unsigned retryCount = 10;
@@ -406,7 +406,7 @@ void Thread::startRelease()
             break;
         else if (0 == --retryCount)
             throw MakeStringException(-1, "Thread::start(%s) failed", getName());
-        WARNLOG("Thread::start(%s) stalled, waiting to start, retrying", getName());
+        IWARNLOG("Thread::start(%s) stalled, waiting to start, retrying", getName());
     }
 #endif
     alive = true;
@@ -589,7 +589,7 @@ void CThreadedPersistent::start()
     if (!state.compare_exchange_strong(expected, s_running))
     {
         VStringBuffer msg("CThreadedPersistent::start(%s) - not ready", athread.getName());
-        WARNLOG("%s", msg.str());
+        IWARNLOG("%s", msg.str());
         PrintStackReport();
         throw MakeStringExceptionDirect(-1, msg.str());
     }
@@ -1025,7 +1025,7 @@ class CThreadPool: public CThreadPoolBase, implements IThreadPool, public CInter
                 if (!availsem.wait(0)) {  // make sure take allocated sem if has become available
                     if (noBlock || timeout > 0)
                         throw MakeStringException(0, "No threads available in pool %s", poolname.get());
-                    WARNLOG("Pool limit exceeded for %s", poolname.get());
+                    IWARNLOG("Pool limit exceeded for %s", poolname.get());
                 }
                 else
                     timedout = false;
@@ -1083,7 +1083,7 @@ public:
     {
         stopAll(true);
         if (!joinAll(true, timeoutOnRelease))
-            WARNLOG("%s; timedout[%d] waiting for threads in pool", poolname.get(), timeoutOnRelease);
+            IWARNLOG("%s; timedout[%d] waiting for threads in pool", poolname.get(), timeoutOnRelease);
         CriticalBlock block(crit);
         bool first=true;
         ForEachItemIn(i,threadwrappers)
@@ -1093,7 +1093,7 @@ public:
             {
                 if (first)
                 {
-                    WARNLOG("Threads still active: ");
+                    IWARNLOG("Threads still active: ");
                     first = false;
                 }
                 StringBuffer threadInfo;
@@ -1322,7 +1322,7 @@ static void CheckAllowedProgram(const char *prog,const char *allowed)
         if (WildMatch(head.str(),list.item(i)))
             return;
     }
-    ERRLOG("Unauthorized pipe program(%s)",head.str());
+    AERRLOG("Unauthorized pipe program(%s)",head.str());
     throw MakeStringException(-1,"Unauthorized pipe program(%s)",head.str());
 }
 
@@ -1444,7 +1444,7 @@ public:
             if (_title) {
                 StringBuffer errstr;
                 formatSystemError(errstr, GetLastError());
-                ERRLOG("%s: PIPE process '%s' failed: %s", title.get(), prog, errstr.str());
+                OERRLOG("%s: PIPE process '%s' failed: %s", title.get(), prog, errstr.str());
             }
             return false;
         }
@@ -1730,7 +1730,7 @@ static unsigned dowaitpid(HANDLE pid, int mode)
                 return WEXITSTATUS(stat);
             else if (WIFSIGNALED(stat))
             {
-                ERRLOG("Program was terminated by signal %u", (unsigned) WTERMSIG(stat));
+                OERRLOG("Program was terminated by signal %u", (unsigned) WTERMSIG(stat));
                 if (WTERMSIG(stat)==SIGPIPE)
                     return 0;
                 return 254;
@@ -1746,7 +1746,7 @@ static unsigned dowaitpid(HANDLE pid, int mode)
         if (err == ECHILD) 
             break;
         if (err!=EINTR) {
-            ERRLOG("dowait failed with errcode %d",err);
+            OERRLOG("dowait failed with errcode %d",err);
             return (unsigned)-1;
         }       
     }
@@ -1811,7 +1811,7 @@ class CLinuxPipeProcess: implements IPipeProcess, public CInterface
                             totsz+=sz;
                         }
                         if (totsz)
-                            WARNLOG("Lost %d bytes of stderr output",totsz);
+                            IWARNLOG("Lost %d bytes of stderr output",totsz);
                     }
                 }
 

+ 4 - 4
system/jlib/jutil.cpp

@@ -464,7 +464,7 @@ HINSTANCE LoadSharedObject(const char *name, bool isGlobal, bool raiseOnError)
         if (h == NULL)
         {
             StringBuffer dlErrorMsg(dlerror());
-            DBGLOG("Warning: Could not load %s: %s", name, dlErrorMsg.str());
+            OWARNLOG("Warning: Could not load %s: %s", name, dlErrorMsg.str());
             if (raiseOnError)
             {
                 if (isCorruptDll(dlErrorMsg.str()))
@@ -2554,11 +2554,11 @@ StringBuffer &getFileAccessUrl(StringBuffer &out)
             const char *host = secureFileAccessInfo->queryProp("@host");
             unsigned port = secureFileAccessInfo->getPropInt("@port", (unsigned)-1);
             if (isEmptyString(protocol))
-                WARNLOG("Missing protocol from secure file access definition");
+                OWARNLOG("Missing protocol from secure file access definition");
             else if (isEmptyString(host))
-                WARNLOG("Missing host from secure file access definition");
+                OWARNLOG("Missing host from secure file access definition");
             else if ((unsigned)-1 == port)
-                WARNLOG("Missing port from secure file access definition");
+                OWARNLOG("Missing port from secure file access definition");
             else
                 out.appendf("%s://%s:%u/WsDfu", protocol, host, port);
         }