浏览代码

Merge pull request #12786 from shamser/issue22255

HPCC-22255 Provide correct audience when logging WU exception

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 5 年之前
父节点
当前提交
eb3f561f10

+ 4 - 0
common/thorhelper/thorcommon.hpp

@@ -620,6 +620,10 @@ public:
     {
         return ctx->getGraphLoopCounter();
     }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char *source) override
+    {
+        ctx->addWuExceptionEx(text, code, severity, audience, source);
+    }
 protected:
     ICodeContext * ctx;
 };

+ 1 - 1
common/thorhelper/thorread.cpp

@@ -259,7 +259,7 @@ bool LocalDiskRowReader::setInputFile(IFile * inputFile, const char * _logicalFi
                 msg.append("Ignoring compression attribute on file ").append(logicalFilename.str()).append(", which is not published as compressed");
                 WARNLOG("%s", msg.str());
                 //MORE: No simple way to do this, unless we are passed an engine context:
-                //agent.addWuException(msg.str(), WRN_MismatchCompressInfo, SeverityWarning, "hthor");
+                //agent.addWuExceptionEx(msg.str(), WRN_MismatchCompressInfo, SeverityWarning, MSGAUD_user, "hthor");
                 compressed = true;
             }
         }

+ 1 - 1
dali/base/dadfs.cpp

@@ -5062,7 +5062,7 @@ protected:
                         {
                             VStringBuffer s("SubFile %s is not owned by SuperFile %s", name, logicalName.get());
                             if (ctx)
-                                ctx->addWuException(s.str(), 0, SeverityWarning, "DFS[clearSuperOwner]");
+                                ctx->addWuExceptionEx(s.str(), 0, SeverityWarning, MSGAUD_user, "DFS[clearSuperOwner]");
                             else
                             {
                                 Owned<IException> e = makeStringException(-1, s.str());

+ 1 - 0
ecl/eclagent/agentctx.hpp

@@ -121,6 +121,7 @@ struct IAgentContext : extends IGlobalCodeContext
 
     virtual void updateWULogfile() = 0;
     virtual bool forceNewDiskReadActivity() const = 0;
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, char const * source) = 0;
 };
 
 #endif // AGENTCTX_HPP_INCL

+ 35 - 22
ecl/eclagent/eclagent.cpp

@@ -1481,9 +1481,16 @@ void EclAgent::addWuException(const char * text, unsigned code, unsigned severit
         addException(mappedSeverity, source, code, text, NULL, 0, 0, false, false);
 }
 
+void EclAgent::addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, char const * source)
+{
+    ErrorSeverity mappedSeverity = wuRead->getWarningSeverity(code, (ErrorSeverity)severity);
+    if (mappedSeverity != SeverityIgnore)
+        addExceptionEx(mappedSeverity, (MessageAudience)audience, source, code, text, NULL, 0, 0, false, false);
+}
+
 void EclAgent::addWuAssertFailure(unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool isAbort)
 {
-    addException(SeverityError, "user", code, text, filename, lineno, column, false, false);
+    addExceptionEx(SeverityError, MSGAUD_user, "user", code, text, filename, lineno, column, false, false);
     if (isAbort)
         throw makeStringException(MSGAUD_user, code, text);
 }
@@ -1650,9 +1657,10 @@ IHThorGraphResults * EclAgent::createGraphLoopResults()
 
 //---------------------------------------------------------------------------
 
-void addException(IWorkUnit *w, ErrorSeverity severity, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError)
+void addException(IWorkUnit *w, ErrorSeverity severity, MessageAudience aud, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError)
 {
-    UERRLOG("%s", text);
+    LOG(mapToLogMsgCategory(severity, aud), "%s", text);
+
     if ((severity == SeverityError) && (w->getState()!=WUStateAborting) && failOnError)
         w->setState(WUStateFailed);
     addExceptionToWorkunit(w, severity, source, code, text, filename, lineno, column, 0);
@@ -1977,7 +1985,7 @@ void EclAgent::doProcess()
                     int code = e->errorCode();
                     VStringBuffer msg("Failed to deschedule workunit %s: ", w->queryWuid());
                     e->errorMessage(msg);
-                    logException(SeverityWarning, code, msg.str(), false);
+                    logException(SeverityWarning, MSGAUD_programmer, code, msg.str(), false);
                     e->Release();
                     UWARNLOG("%s (%d)", msg.str(), code);
                 }
@@ -2049,7 +2057,7 @@ void EclAgent::doProcess()
             StringBuffer m("System error ");
             m.append(e->errorCode()).append(": ");
             e->errorMessage(m);
-            ::addException(w, SeverityError, "eclagent", e->errorCode(), m.str(), NULL, 0, 0, true);
+            ::addException(w, SeverityError, MSGAUD_programmer, "eclagent", e->errorCode(), m.str(), NULL, 0, 0, true);
         }
         catch (IException *e2)
         {
@@ -2289,7 +2297,7 @@ void EclAgentWorkflowMachine::reportContingencyFailure(char const * type, IExcep
     StringBuffer msg;
     msg.append(type).append(" clause failed (execution will continue): ").append(e->errorCode()).append(": ");
     e->errorMessage(msg);
-    agent.logException(SeverityWarning, e->errorCode(), msg.str(), false);
+    agent.logException(SeverityWarning, MSGAUD_user, e->errorCode(), msg.str(), false);
 }
 
 void EclAgentWorkflowMachine::checkForAbort(unsigned wfid, IException * handling)
@@ -2302,7 +2310,7 @@ void EclAgentWorkflowMachine::checkForAbort(unsigned wfid, IException * handling
             msg.append("Abort takes precedence over error: ").append(handling->errorCode()).append(": ");
             handling->errorMessage(msg);
             msg.append(" (in item ").append(wfid).append(")");
-            agent.logException(SeverityWarning, handling->errorCode(), msg.str(), false);
+            agent.logException(SeverityWarning, MSGAUD_user, handling->errorCode(), msg.str(), false);
             handling->Release();
         }
         throw new WorkflowException(0, "Workunit abort request received", wfid, WorkflowException::ABORT, MSGAUD_user);
@@ -2427,15 +2435,18 @@ void EclAgent::doNotify(char const * name, char const * text, const char * targe
     pusher->push(name, text, target);
 }
 
-void EclAgent::logException(ErrorSeverity severity, unsigned code, const char * text, bool isAbort)
+void EclAgent::logException(ErrorSeverity severity, MessageAudience aud, unsigned code, const char * text, bool isAbort)
 {
-    addException(severity, "eclagent", code, text, NULL, 0, 0, true, isAbort);
-    if (severity == SeverityError)
-        UERRLOG(code, "%s", text);
+    addExceptionEx(severity, aud, "eclagent", code, text, NULL, 0, 0, true, isAbort);
 }
 
 void EclAgent::addException(ErrorSeverity severity, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError, bool isAbort)
 {
+    addExceptionEx(severity, MSGAUD_programmer, source, code, text, filename, lineno, column, failOnError, isAbort);
+}
+
+void EclAgent::addExceptionEx(ErrorSeverity severity, MessageAudience aud, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError, bool isAbort)
+{
     if (writeResultsToStdout && (severity != SeverityInformation))
     {
         StringBuffer location;
@@ -2454,7 +2465,7 @@ void EclAgent::addException(ErrorSeverity severity, const char * source, unsigne
         WorkunitUpdate w = updateWorkUnit();
         if(isAbort)
             w->setState(WUStateAborting);
-        ::addException(w, severity, source, code, text, filename, lineno, column, failOnError);
+        ::addException(w, severity, aud, source, code, text, filename, lineno, column, failOnError);
     }
     catch (IException *E)
     {
@@ -2482,6 +2493,7 @@ void EclAgent::logException(WorkflowException *e)
     StringBuffer m;
     unsigned code = 0;
     bool isAbort = false;
+    MessageAudience aud = MSGAUD_user;
     if(e)
     {
         switch(e->queryType())
@@ -2490,6 +2502,7 @@ void EclAgent::logException(WorkflowException *e)
             m.append("Error: ");
             break;
         case WorkflowException::SYSTEM:
+            aud = MSGAUD_programmer;
             m.append("System error: ");
             break;
         case WorkflowException::ABORT:
@@ -2506,7 +2519,7 @@ void EclAgent::logException(WorkflowException *e)
     else    
         m.append("Unknown error");
 
-    logException(SeverityError, code, m.str(), isAbort);
+    logException(SeverityError, aud, code, m.str(), isAbort);
 }
 
 void EclAgent::logException(IException *e)
@@ -2526,7 +2539,7 @@ void EclAgent::logException(IException *e)
     else    
         m.append("Unknown error");
 
-    logException(SeverityError, code, m.str(), false);
+    logException(SeverityError, MSGAUD_programmer, code, m.str(), false);
 }
 
 void EclAgent::logException(std::exception & e)
@@ -2536,7 +2549,7 @@ void EclAgent::logException(std::exception & e)
         m.append("out of memory (std::bad_alloc)");
     else
         m.append("standard library exception (std::exception ").append(e.what()).append(")");
-    logException(SeverityError, 0, m.str(), false);
+    logException(SeverityError, MSGAUD_programmer, 0, m.str(), false);
 }
 
 static unsigned __int64 crcLogicalFileTime(IDistributedFile * file, unsigned __int64 crc, const char * filename)
@@ -2726,12 +2739,12 @@ bool EclAgent::isPersistUptoDate(Owned<IRemoteConnection> &persistLock, IRuntime
         if (checkPersistUptoDate(item, logicalName, eclCRC, allCRC, isFile, dummy) && !rebuildAllPersists)
         {
             if (dummy.length())
-                logException(SeverityInformation, 0, dummy.str(), false);
+                logException(SeverityInformation, MSGAUD_user, 0, dummy.str(), false);
             else
             {
                 StringBuffer msg;
                 msg.append("PERSIST('").append(logicalName).append("') is up to date");
-                logException(SeverityInformation, 0, msg.str(), false);
+                logException(SeverityInformation, MSGAUD_user, 0, msg.str(), false);
             }
             return true;
         }
@@ -2756,19 +2769,19 @@ bool EclAgent::isPersistUptoDate(Owned<IRemoteConnection> &persistLock, IRuntime
         if (errText.length())
         {
             errText.append(" (after being calculated by another job)");
-            logException(SeverityInformation, 0, errText.str(), false);
+            logException(SeverityInformation, MSGAUD_user, 0, errText.str(), false);
         }
         else
         {
             StringBuffer msg;
             msg.append("PERSIST('").append(logicalName).append("') is up to date (after being calculated by another job)");
-            logException(SeverityInformation, 0, msg.str(), false);
+            logException(SeverityInformation, MSGAUD_user, 0, msg.str(), false);
         }
         changePersistLockMode(persistLock, RTM_LOCK_READ, logicalName, true);
         return true;
     }
     if (errText.length())
-        logException(SeverityInformation, 0, errText.str(), false);
+        logException(SeverityInformation, MSGAUD_user, 0, errText.str(), false);
     return false;
 }
 
@@ -2822,7 +2835,7 @@ void EclAgent::checkPersistMatches(const char * logicalName, unsigned eclCRC)
 
     StringBuffer msg;
     msg.append("Frozen PERSIST('").append(logicalName).append("') is up to date");
-    logException(SeverityInformation, 0, msg.str(), false);
+    logException(SeverityInformation, MSGAUD_user, 0, msg.str(), false);
 }
 
 static int comparePersistAccess(IInterface * const *_a, IInterface * const *_b)
@@ -3207,7 +3220,7 @@ void EclAgent::fatalAbort(bool userabort,const char *excepttext)
         if (userabort) 
             w->setState(WUStateAborted);
         if (excepttext&&*excepttext)
-            addException(SeverityError, "eclagent", 1000, excepttext, NULL, 0, 0, true, false);
+            addExceptionEx(SeverityError, MSGAUD_programmer, "eclagent", 1000, excepttext, NULL, 0, 0, true, false);
         w->deleteTempFiles(NULL, false, true);
         wuRead.clear(); 
         w->commit();        // needed because we can't unlock the workunit in this thread

+ 7 - 1
ecl/eclagent/eclagent.ipp

@@ -242,6 +242,10 @@ public:
     {
         return ctx->forceNewDiskReadActivity();
     }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, char const * source) override
+    {
+        ctx->addWuExceptionEx(text, code, severity, audience, source);
+    }
 
 protected:
     IAgentContext * ctx;
@@ -495,6 +499,7 @@ public:
     virtual bool fileExists(const char * filename);
     virtual char * getExpandLogicalName(const char * logicalName);
     virtual void addWuException(const char * text, unsigned code, unsigned severity, char const * source);
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, char const * source);
     virtual void addWuAssertFailure(unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool isAbort);
     virtual IUserDescriptor *queryUserDescriptor();
     virtual void selectCluster(const char * cluster);
@@ -591,10 +596,11 @@ public:
     virtual void deleteFile(const char * logicalName);
 
     void addException(ErrorSeverity severity, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError, bool isAbort);
+    void addExceptionEx(ErrorSeverity severity, MessageAudience aud, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool failOnError, bool isAbort);
     void logException(IException *e);  
     void logException(WorkflowException *e);  
     void logException(std::exception & e);
-    void logException(ErrorSeverity severity, unsigned code, const char * text, bool isAbort);
+    void logException(ErrorSeverity severity, MessageAudience aud, unsigned code, const char * text, bool isAbort);
 
     void doProcess();
     void runProcess(IEclProcess *process);

+ 1 - 0
ecl/hql/hqlfold.cpp

@@ -1541,6 +1541,7 @@ class DummyContext: implements ICodeContext
     virtual IWorkUnit* updateWorkUnit() const { throwUnexpected(); }
     virtual ISectionTimer * registerTimer(unsigned activityId, const char * name) { throwUnexpected(); }
     virtual IEngineRowAllocator * getRowAllocatorEx(IOutputMetaData * meta, unsigned activityId, unsigned flags) const { throwUnexpected(); }
+    virtual void addWuExceptionEx(const char*, unsigned int, unsigned int, unsigned int, const char*) override { throwUnexpected(); }
 
 };
 

+ 7 - 12
ecl/hthor/hthor.cpp

@@ -4001,7 +4001,7 @@ void CHThorGroupSortActivity::createSorter()
     {
         StringBuffer sb;
         sb.appendf("Ignoring unsupported sort order algorithm '%s', using default", algoname.get());
-        agent.addWuException(sb.str(),WRN_UnsupportedAlgorithm,SeverityWarning,"hthor");
+        agent.addWuExceptionEx(sb.str(),WRN_UnsupportedAlgorithm,SeverityWarning,MSGAUD_user,"hthor");
         if((flags & TAFunstable) != 0)
             sorter.setown(new CQuickSorter(helper.queryCompare(), queryRowManager(), InitialSortElements, CommitStep));
         else
@@ -8213,8 +8213,7 @@ void CHThorDiskReadBaseActivity::resolve()
         {
             StringBuffer buff;
             buff.appendf("Input file '%s' was missing but declared optional", mangledHelperFileName.str());
-            UWARNLOG("%s", buff.str());
-            agent.addWuException(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, "hthor");
+            agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, MSGAUD_user, "hthor");
         }
     }
 }
@@ -8230,8 +8229,7 @@ void CHThorDiskReadBaseActivity::gatherInfo(IFileDescriptor * fileDesc)
             {
                 StringBuffer msg;
                 msg.append("DFS and code generated group info. differs: DFS(").append(grouped ? "grouped" : "ungrouped").append("), CodeGen(").append(grouped ? "ungrouped" : "grouped").append("), using DFS info");
-                UWARNLOG("%s", msg.str());
-                agent.addWuException(msg.str(), WRN_MismatchGroupInfo, SeverityError, "hthor");
+                agent.addWuExceptionEx(msg.str(), WRN_MismatchGroupInfo, SeverityError, MSGAUD_user, "hthor");
             }
         }
         else
@@ -8255,8 +8253,7 @@ void CHThorDiskReadBaseActivity::gatherInfo(IFileDescriptor * fileDesc)
             {
                 StringBuffer msg;
                 msg.append("Ignoring compression attribute on file ").append(mangledHelperFileName.str()).append(", which is not published as compressed");
-                UWARNLOG("%s", msg.str());
-                agent.addWuException(msg.str(), WRN_MismatchCompressInfo, SeverityWarning, "hthor");
+                agent.addWuExceptionEx(msg.str(), WRN_MismatchCompressInfo, SeverityWarning, MSGAUD_user, "hthor");
                 compressed = true;
             }
         }
@@ -8432,7 +8429,7 @@ bool CHThorDiskReadBaseActivity::openNext()
 #endif
                                 VStringBuffer msg("Remote streaming failure, failing over to direct read for: '%s'. ", file.str());
                                 e->errorMessage(msg);
-                                agent.addWuException(msg.str(), WRN_RemoteReadFailure, SeverityWarning, "hthor");
+                                agent.addWuExceptionEx(msg.str(), WRN_RemoteReadFailure, SeverityWarning, MSGAUD_user, "hthor");
                                 e->Release();
                                 continue; // try next copy and ultimately failover to local when no more copies
                             }
@@ -10559,8 +10556,7 @@ void CHThorNewDiskReadBaseActivity::resolveFile()
         {
             StringBuffer buff;
             buff.appendf("Input file '%s' was missing but declared optional", mangledHelperFileName.str());
-            WARNLOG("%s", buff.str());
-            agent.addWuException(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, "hthor");
+            agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, MSGAUD_user, "hthor");
         }
     }
 
@@ -10578,8 +10574,7 @@ void CHThorNewDiskReadBaseActivity::gatherInfo(IFileDescriptor * fileDesc)
             {
                 StringBuffer msg;
                 msg.append("DFS and code generated group info. differs: DFS(").append(grouped ? "grouped" : "ungrouped").append("), CodeGen(").append(grouped ? "ungrouped" : "grouped").append("), using DFS info");
-                WARNLOG("%s", msg.str());
-                agent.addWuException(msg.str(), WRN_MismatchGroupInfo, SeverityError, "hthor");
+                agent.addWuExceptionEx(msg.str(), WRN_MismatchGroupInfo, SeverityError, MSGAUD_user, "hthor");
             }
         }
         else

+ 8 - 16
ecl/hthor/hthorkey.cpp

@@ -1095,8 +1095,7 @@ extern HTHOR_API IHThorActivity *createIndexReadActivity(IAgentContext &_agent,
     {
         StringBuffer buff;
         buff.append("Skipping OPT index read of nonexistent file ").append(lfn);
-        UWARNLOG("%s", buff.str());
-        _agent.addWuException(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, "hthor");
+        _agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, MSGAUD_user, "hthor");
         return new CHThorNullActivity(_agent, _activityId, _subgraphId, arg, _kind);
     }
     _agent.logFileAccess(dFile, "HThor", "READ");
@@ -1278,8 +1277,7 @@ extern HTHOR_API IHThorActivity *createIndexNormalizeActivity(IAgentContext &_ag
     {
         StringBuffer buff;
         buff.append("Skipping OPT index normalize of nonexistent file ").append(lfn);
-        UWARNLOG("%s", buff.str());
-        _agent.addWuException(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, "hthor");
+        _agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, MSGAUD_user, "hthor");
         return new CHThorNullActivity(_agent, _activityId, _subgraphId, arg, _kind);
     }
     _agent.logFileAccess(dFile, "HThor", "READ");
@@ -1396,8 +1394,7 @@ extern HTHOR_API IHThorActivity *createIndexAggregateActivity(IAgentContext &_ag
     {
         StringBuffer buff;
         buff.append("Skipping OPT index aggregate of nonexistent file ").append(lfn);
-        UWARNLOG("%s", buff.str());
-        _agent.addWuException(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, "hthor");
+        _agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, MSGAUD_user, "hthor");
         return new CHThorNullAggregateActivity(_agent, _activityId, _subgraphId, arg, arg, _kind);
     }
     _agent.logFileAccess(dFile, "HThor", "READ");
@@ -1553,8 +1550,7 @@ extern HTHOR_API IHThorActivity *createIndexCountActivity(IAgentContext &_agent,
     {
         StringBuffer buff;
         buff.append("Skipping OPT index count of nonexistent file ").append(lfn);
-        UWARNLOG("%s", buff.str());
-        _agent.addWuException(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, "hthor");
+        _agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, MSGAUD_user, "hthor");
         return new CHThorNullCountActivity(_agent, _activityId, _subgraphId, arg, _kind);
     }
     _agent.logFileAccess(dFile, "HThor", "READ");
@@ -1665,8 +1661,7 @@ extern HTHOR_API IHThorActivity *createIndexGroupAggregateActivity(IAgentContext
     {
         StringBuffer buff;
         buff.append("Skipping OPT index group aggregate of nonexistent file ").append(lfn);
-        UWARNLOG("%s", buff.str());
-        _agent.addWuException(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, "hthor");
+        _agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptIndex, SeverityInformation, MSGAUD_user, "hthor");
         return new CHThorNullActivity(_agent, _activityId, _subgraphId, arg, _kind);
     }
     _agent.logFileAccess(dFile, "HThor", "READ");
@@ -2284,8 +2279,7 @@ public:
             {
                 StringBuffer buff;
                 buff.append("Skipping OPT fetch of nonexistent file ").append(lfn);
-                UWARNLOG("%s", buff.str());
-                agent.addWuException(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, "hthor");
+                agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, MSGAUD_user, "hthor");
             }
         }
         inputThread.setown(new InputHandler(this));
@@ -2608,8 +2602,7 @@ public:
         {
             StringBuffer buff;
             buff.append("Skipping OPT fetch of nonexistent file ").append(lfn);
-            UWARNLOG("%s", buff.str());
-            agent.addWuException(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, "hthor");
+            agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, MSGAUD_user, "hthor");
         }
             
         csvSplitter.init(_arg.getMaxColumns(), csvInfo, quotes, separators, terminators, escapes);
@@ -4060,8 +4053,7 @@ public:
         {
             StringBuffer buff;
             buff.append("Skipping OPT keyed join against nonexistent file ").append(lfn);
-            UWARNLOG("%s", buff.str());
-            agent.addWuException(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, "hthor");
+            agent.addWuExceptionEx(buff.str(), WRN_SkipMissingOptFile, SeverityInformation, MSGAUD_user, "hthor");
         }
         CHThorThreadedActivityBase::start();
     }

+ 1 - 1
plugins/fileservices/fileservices.cpp

@@ -365,7 +365,7 @@ static void WUmessage(ICodeContext *ctx, ErrorSeverity sev, const char *fn, cons
     StringBuffer s("fileservices");
     if (fn)
         s.append(", ").append(fn);
-    ctx->addWuException(msg, 0, sev, s.str()); // use plain code context
+    ctx->addWuExceptionEx(msg, 0, sev, MSGAUD_audit, s.str()); // use plain code context
     return;
 }
 

+ 3 - 0
plugins/logging/logging.cpp

@@ -34,6 +34,9 @@ static const char * EclDefinition =
 "  addWorkunitInformation(const varstring txt, unsigned code=0, unsigned severity=0, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
 "  addWorkunitWarning(const varstring txt, unsigned code=0, unsigned severity=1, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
 "  addWorkunitError(const varstring txt, unsigned code=0, unsigned severity=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
+"  addWorkunitInformationEx(const varstring txt, unsigned code=0, unsigned severity=0, unsigned audience=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuExceptionEx'; \n"
+"  addWorkunitWarningEx(const varstring txt, unsigned code=0, unsigned severity=1, unsigned audience=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuExceptionEx'; \n"
+"  addWorkunitErrorEx(const varstring txt, unsigned code=0, unsigned severity=2, unsigned audience=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuExceptionEx'; \n"
 "  varstring getGlobalId() : c,context,entrypoint='logGetGlobalId'; \n"
 "  varstring getLocalId() : c,context,entrypoint='logGetLocalId'; \n"
 "  varstring getCallerId() : c,context,entrypoint='logGetCallerId'; \n"

+ 1 - 0
roxie/ccd/ccdactivities.cpp

@@ -633,6 +633,7 @@ public:
     virtual unsigned getGraphLoopCounter() const override { return queryContext->queryCodeContext()->getGraphLoopCounter(); }
     virtual IEclGraphResults * resolveLocalQuery(__int64 activityId) override { return NULL; } // Only want to do this on the server
     virtual IDebuggableContext *queryDebugContext() const override { return queryContext->queryCodeContext()->queryDebugContext(); }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char * source) override { throwUnexpected(); }
 
 };
 

+ 8 - 2
roxie/ccd/ccdcontext.cpp

@@ -2067,6 +2067,7 @@ public:
         }
         return timer;
     }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char * source) override { throwUnexpected(); }
 
 protected:
     mutable CriticalSection contextCrit;
@@ -3696,10 +3697,15 @@ public:
 
     virtual void addWuException(const char * text, unsigned code, unsigned _severity, const char * source)
     {
+        addWuExceptionEx(text, code, _severity, MSGAUD_operator, source);
+    }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned _severity, unsigned audience, const char * source)
+    {
         ErrorSeverity severity = (ErrorSeverity) _severity;
         CTXLOG("%s", text);
         if (severity > SeverityInformation)
-            OERRLOG("%d - %s", code, text);
+            LOG(mapToLogMsgCategory(severity, (MessageAudience)audience), "%d - %s", code, text);
+
         if (workUnit)
         {
             WorkunitUpdate wu(&workUnit->lock());
@@ -3853,7 +3859,7 @@ public:
     }
     virtual void fail(int code, const char *text)
     {
-        addWuException(text, code, 2, "user");
+        addWuExceptionEx(text, code, 2, MSGAUD_user, "user");
     }
 
     virtual unsigned getWorkflowId() { return workflow->queryCurrentWfid(); }

+ 1 - 1
roxie/ccd/ccddali.cpp

@@ -913,7 +913,7 @@ extern void addWuException(IConstWorkUnit *workUnit, IException *E)
     StringBuffer message;
     E->errorMessage(message);
     unsigned code = E->errorCode();
-    OERRLOG("%u - %s", code, message.str());
+    IERRLOG("%u - %s", code, message.str());
     WorkunitUpdate w(&workUnit->lock());
     addExceptionToWorkunit(w, SeverityError, "Roxie", code, message.str(), NULL, 0, 0, 0);
 }

+ 2 - 1
rtl/include/eclhelper.hpp

@@ -44,7 +44,7 @@ typedef unsigned short UChar;
 
 //Should be incremented whenever the virtuals in the context or a helper are changed, so
 //that a work unit can't be rerun.  Try as hard as possible to retain compatibility.
-#define ACTIVITY_INTERFACE_VERSION      650
+#define ACTIVITY_INTERFACE_VERSION      651
 #define MIN_ACTIVITY_INTERFACE_VERSION  650             //minimum value that is compatible with current interface
 
 typedef unsigned char byte;
@@ -769,6 +769,7 @@ interface ICodeContext : public IResourceContext
     virtual unsigned getExternalResultHash(const char * wuid, const char * name, unsigned sequence) = 0;
     virtual ISectionTimer * registerTimer(unsigned activityId, const char * name) = 0;
     virtual IEngineRowAllocator * getRowAllocatorEx(IOutputMetaData * meta, unsigned activityId, unsigned flags) const = 0;
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char * source) = 0;
 };
 
 

+ 53 - 0
system/jlib/jexcept.cpp

@@ -1736,5 +1736,58 @@ void IErrorReceiver::reportWarning(WarnErrorCategory category, int warnNo, const
     report(warn);
 }
 
+const LogMsgCategory & mapToLogMsgCategory(ErrorSeverity severity, MessageAudience aud)
+{
+    switch (severity)
+    {
+        case SeverityIgnore:
+        case SeverityInformation:
+        {
+            switch (aud)
+            {
+                case MSGAUD_operator:
+                    return MCoperatorInfo;
+                case MSGAUD_user:
+                    return MCuserInfo;
+                case MSGAUD_audit:
+                    return MCauditInfo;
+                default:
+                    return MCdebugInfo;
+            }
+        }
+        case SeverityAlert:
+        case SeverityWarning:
+        {
+            switch (aud)
+            {
+                case MSGAUD_operator:
+                    return MCoperatorWarning;
+                case MSGAUD_user:
+                    return MCuserWarning;
+                case MSGAUD_audit:
+                    return MCauditWarning;
+                default:
+                    return MCinternalWarning;
+            }
+        }
+        case SeverityFatal:
+        case SeverityError:
+        {
+            switch (aud)
+            {
+                case MSGAUD_operator:
+                    return MCoperatorError;
+                case MSGAUD_user:
+                    return MCuserError;
+                case MSGAUD_audit:
+                    return MCauditError;
+                default:
+                    return MCinternalError;
+            }
+        }
+    }
+    return MCdebugInfo;
+}
+
 //---------------------------------------------------------------------------------------------------------------------
 

+ 2 - 0
system/jlib/jexcept.hpp

@@ -261,6 +261,8 @@ inline IError * createError(int errNo, const char *msg, const char *filename, in
 }
 
 extern jlib_decl const char * querySeverityString(ErrorSeverity errorSeverity);
+class LogMsgCategory;
+extern jlib_decl const LogMsgCategory & mapToLogMsgCategory(ErrorSeverity severity, MessageAudience aud);
 
 #endif
 

+ 1 - 0
thorlcr/graph/thgraph.hpp

@@ -584,6 +584,7 @@ class graph_decl CGraphBase : public CGraphStub, implements IEclGraphResults
         {
             return ctx->registerTimer(activityId, name);
         }
+        virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char * source) override { ctx->addWuExceptionEx(text, code, severity, audience, source); }
    } graphCodeContext;
 
 protected:

+ 26 - 22
thorlcr/graph/thgraphmaster.cpp

@@ -1142,28 +1142,7 @@ public:
     }
     virtual void addWuException(const char * text, unsigned code, unsigned severity, const char * source) override
     {
-        DBGLOG("%s", text);
-        try
-        {
-            Owned<IWorkUnit> w = updateWorkUnit();
-            Owned<IWUException> we = w->createException();
-            we->setSeverity((ErrorSeverity)severity);
-            we->setExceptionMessage(text);
-            we->setExceptionSource(source);
-            if (code)
-                we->setExceptionCode(code);
-        }
-        catch (IException *E)
-        {
-            StringBuffer m;
-            E->errorMessage(m);
-            IERRLOG("Unable to record exception in workunit: %s", m.str());
-            E->Release();
-        }
-        catch (...)
-        {
-            IERRLOG("Unable to record exception in workunit: unknown exception");
-        }
+        addWuExceptionEx(text, code, severity, MSGAUD_programmer, source);
     }
     virtual void addWuAssertFailure(unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column, bool isAbort) override
     {
@@ -1255,6 +1234,31 @@ public:
     {
         return &workunit->lock();
     }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned audience, const char * source) override
+    {
+        LOG(mapToLogMsgCategory((ErrorSeverity)severity, (MessageAudience)audience), "%s", text);
+        try
+        {
+            Owned<IWorkUnit> w = updateWorkUnit();
+            Owned<IWUException> we = w->createException();
+            we->setSeverity((ErrorSeverity)severity);
+            we->setExceptionMessage(text);
+            we->setExceptionSource(source);
+            if (code)
+                we->setExceptionCode(code);
+        }
+        catch (IException *E)
+        {
+            StringBuffer m;
+            E->errorMessage(m);
+            IERRLOG("Unable to record exception in workunit: %s", m.str());
+            E->Release();
+        }
+        catch (...)
+        {
+            IERRLOG("Unable to record exception in workunit: unknown exception");
+        }
+    }
 };
 
 class CThorCodeContextMasterSharedMem : public CThorCodeContextMaster

+ 5 - 1
thorlcr/graph/thgraphslave.cpp

@@ -1485,7 +1485,11 @@ public:
 
     virtual void addWuException(const char * text, unsigned code, unsigned severity, const char * source)
     {
-        DBGLOG("%s", text);
+        addWuExceptionEx(text, code, severity, MSGAUD_programmer, source);
+    }
+    virtual void addWuExceptionEx(const char * text, unsigned code, unsigned severity, unsigned aud, const char * source)
+    {
+        LOG(mapToLogMsgCategory((ErrorSeverity)severity, (MessageAudience)aud), "%s", text);
         Owned<IThorException> e = MakeThorException(code, "%s", text);
         e->setOrigin(source);
         e->setAction(tea_warning);

+ 1 - 0
tools/wutool/wutool.cpp

@@ -2096,6 +2096,7 @@ protected:
             virtual char *getDaliServers() { throwUnexpected(); }
             virtual IWorkUnit* updateWorkUnit() const { throwUnexpected(); }
             virtual ISectionTimer * registerTimer(unsigned activityId, const char * name) { throwUnexpected(); }
+            virtual void addWuExceptionEx(const char*, unsigned int, unsigned int, unsigned int, const char*) override { throwUnexpected(); }
         } ctx;
 
  #if 0