Pārlūkot izejas kodu

HPCC-21580 Add constexpr to LogMsgCategory

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Shamser Ahmed 6 gadi atpakaļ
vecāks
revīzija
ed0b5d8429

+ 1 - 1
common/remote/rmtspawn.cpp

@@ -29,7 +29,7 @@
 
 
 
-LogMsgCategory MCdetailDebugInfo(MCdebugInfo(1000));
+constexpr LogMsgCategory MCdetailDebugInfo(MCdebugInfo(1000));
 
 /*
 How the remote spawning works:

+ 0 - 4
common/workunit/workflow.cpp

@@ -603,10 +603,6 @@ private:
 
 //-------------------------------------------------------------------------------------------------
 
-#ifdef TRACE_WORKFLOW
-const LogMsgCategory MCworkflow = MCprogress(50);       // Category used to inform enqueue/start/finish of workflow item
-#endif
-
 WorkflowMachine::WorkflowMachine()
     : ctx(NULL), process(NULL), currentWfid(0), currentScheduledWfid(0), itemsWaiting(0), itemsUnblocked(0), condition(false), logctx(queryDummyContextLogger())
 {

+ 1 - 1
common/workunit/workflow.hpp

@@ -142,7 +142,7 @@ extern WORKUNIT_API const char * queryWorkflowModeText(WFMode mode);
 extern WORKUNIT_API const char * queryWorkflowStateText(WFState state);
 
 #ifdef TRACE_WORKFLOW
-extern const WORKUNIT_API LogMsgCategory MCworkflow;       // Category used to inform enqueue/start/finish of workflow item
+constexpr LogMsgCategory MCworkflow = MCprogress(50); // Category used to inform enqueue/start/finish of workflow item
 #endif
 
 #endif

+ 1 - 1
common/workunit/workunit.cpp

@@ -12491,7 +12491,7 @@ extern WORKUNIT_API WUState getWorkUnitState(const char* state)
     return (WUState) getEnum(state, states);
 }
 
-const LogMsgCategory MCschedconn = MCprogress(1000);    // Category used to inform about schedule synchronization
+constexpr LogMsgCategory MCschedconn = MCprogress(1000);    // Category used to inform about schedule synchronization
 
 class CWorkflowScheduleConnection : implements IWorkflowScheduleConnection, public CInterface
 {

+ 0 - 3
dali/base/daaudit.cpp

@@ -38,9 +38,6 @@
 #pragma warning (disable : 4355)
 #endif
 
-LogMsgCategory const daliAuditLogCat(MSGAUD_audit, MSGCLS_information, DefaultDetail);
-
-
 enum MAuditRequestKind { 
     MAR_QUERY
 };

+ 1 - 3
dali/base/daaudit.hpp

@@ -30,8 +30,6 @@ extern da_decl unsigned queryAuditLogs(const CDateTime &from,const CDateTime &to
 interface IDaliServer;
 extern da_decl IDaliServer *createDaliAuditServer(const char *dir); // called for coven members
 
-extern da_decl LogMsgCategory const daliAuditLogCat;
-
-
+constexpr LogMsgCategory daliAuditLogCat(MSGAUD_audit, MSGCLS_information, DefaultDetail);
 
 #endif

+ 0 - 3
dali/ft/daftmc.cpp

@@ -19,6 +19,3 @@
 
 #include "daftmc.hpp"
 
-const LogMsgCategory MCdebugInfoDetail(MCdebugInfo(1000));
-const LogMsgCategory MCdebugProgressDetail(MCdebugProgress(1000));
-

+ 2 - 2
dali/ft/daftmc.hpp

@@ -20,7 +20,7 @@
 
 #include "daft.hpp"
 
-extern DALIFT_API const LogMsgCategory MCdebugInfoDetail;
-extern DALIFT_API const LogMsgCategory MCdebugProgressDetail;
+constexpr LogMsgCategory MCdebugInfoDetail(MCdebugInfo(1000));
+constexpr LogMsgCategory MCdebugProgressDetail(MCdebugProgress(1000));
 
 #endif

+ 4 - 4
ecl/eclagent/eclagent.cpp

@@ -81,10 +81,10 @@ static const char XMLHEADER[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
 
 typedef IEclProcess* (* EclProcessFactory)();
 
-const LogMsgCategory MCsetresult = MCprogress(100);     // Category used to inform when setting result
-const LogMsgCategory MCgetresult = MCprogress(200);     // Category used to inform when getting result
-const LogMsgCategory MCresolve = MCprogress(100);       // Category used to inform during name resolution
-const LogMsgCategory MCrunlock = MCprogress(100);      // Category used to inform about run lock progress
+constexpr LogMsgCategory MCsetresult = MCprogress(100);     // Category used to inform when setting result
+constexpr LogMsgCategory MCgetresult = MCprogress(200);     // Category used to inform when getting result
+constexpr LogMsgCategory MCresolve = MCprogress(100);       // Category used to inform during name resolution
+constexpr LogMsgCategory MCrunlock = MCprogress(100);      // Category used to inform about run lock progress
 
 Owned<IPropertyTree> agentTopology;
 

+ 0 - 17
system/jlib/jlog.cpp

@@ -2180,23 +2180,6 @@ void attachManyLogMsgMonitorsFromPTree(IPropertyTree * tree)
         attachLogMsgMonitorFromPTree(&(iter->query()));
 }
 
-// Standard categories and unknown jobInfo
-
-const LogMsgCategory MCdisaster(MSGAUD_all, MSGCLS_disaster);
-const LogMsgCategory MCuserError(MSGAUD_user, MSGCLS_error);
-const LogMsgCategory MCoperatorError(MSGAUD_operator, MSGCLS_error);
-const LogMsgCategory MCinternalError(MSGAUD_programmer, MSGCLS_error, 1);
-const LogMsgCategory MCuserWarning(MSGAUD_user, MSGCLS_warning);
-const LogMsgCategory MCoperatorWarning(MSGAUD_operator, MSGCLS_warning);
-const LogMsgCategory MCinternalWarning(MSGAUD_programmer, MSGCLS_warning, 1);
-const LogMsgCategory MCuserProgress(MSGAUD_user, MSGCLS_progress);
-const LogMsgCategory MCoperatorProgress(MSGAUD_operator, MSGCLS_progress);
-const LogMsgCategory MCdebugProgress(MSGAUD_programmer, MSGCLS_progress);
-const LogMsgCategory MCdebugInfo(MSGAUD_programmer, MSGCLS_information);
-const LogMsgCategory MCstats(MSGAUD_operator, MSGCLS_progress);
-const LogMsgCategory MCoperatorInfo(MSGAUD_operator, MSGCLS_information);
-const LogMsgCategory MClegacy(MSGAUD_legacy, MSGCLS_legacy, DefaultDetail);
-
 const LogMsgJobInfo unknownJob(UnknownJob, UnknownUser);
 
 // Calls to make, remove, and return the manager, standard handler, pass all/none filters, reporter array

+ 22 - 22
system/jlib/jlog.hpp

@@ -345,10 +345,10 @@ inline char const * msgPrefix(LogMsgClass msgClass)
 class jlib_decl LogMsgCategory
 {
 public:
-    LogMsgCategory(LogMsgAudience _audience = MSGAUD_programmer, LogMsgClass _class = MSGCLS_information, LogMsgDetail _detail = DefaultDetail) : audience(_audience), msgClass(_class), detail(_detail) {}
-    inline LogMsgAudience     queryAudience() const { return audience; }
-    inline LogMsgClass        queryClass() const { return msgClass; }
-    inline LogMsgDetail       queryDetail() const { return detail; }
+    constexpr LogMsgCategory(LogMsgAudience _audience = MSGAUD_programmer, LogMsgClass _class = MSGCLS_information, LogMsgDetail _detail = DefaultDetail) : audience(_audience), msgClass(_class), detail(_detail) {}
+    constexpr LogMsgAudience  queryAudience() const { return audience; }
+    constexpr LogMsgClass     queryClass() const { return msgClass; }
+    constexpr LogMsgDetail    queryDetail() const { return detail; }
     void                      serialize(MemoryBuffer & out) const { out.append(audience).append(msgClass).append(detail); }
     void                      deserialize(MemoryBuffer & in)
     {
@@ -357,7 +357,7 @@ public:
         msgClass = (LogMsgClass) c;
         detail = (LogMsgDetail) d;
     }
-    LogMsgCategory const      operator ()(unsigned newDetail) const { return LogMsgCategory(audience, msgClass, newDetail); }
+    constexpr LogMsgCategory  operator ()(unsigned newDetail) const { return LogMsgCategory(audience, msgClass, newDetail); }
 private:
     LogMsgAudience            audience;
     LogMsgClass               msgClass;
@@ -664,27 +664,27 @@ extern jlib_decl ILogMsgHandler * getLogMsgHandlerFromPTree(IPropertyTree * tree
 extern jlib_decl ILogMsgHandler * attachLogMsgMonitorFromPTree(IPropertyTree * tree);     // Takes tree containing <handler> and <filter> elements
 extern jlib_decl void attachManyLogMsgMonitorsFromPTree(IPropertyTree * tree);            // Takes tree containing many <monitor> elements
 
-// Extern standard categories and unknown jobInfo
+// Standard categories and unknown jobInfo
+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 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 MCdebugInfo(MSGAUD_programmer, MSGCLS_information);
+constexpr LogMsgCategory MCstats(MSGAUD_operator, MSGCLS_progress);
+constexpr LogMsgCategory MCoperatorInfo(MSGAUD_operator, MSGCLS_information);
+constexpr LogMsgCategory MClegacy(MSGAUD_legacy, MSGCLS_legacy, DefaultDetail);
+
+inline LogMsgCategory MCexception(IException * e, LogMsgClass cls = MSGCLS_error) { return LogMsgCategory((e)->errorAudience(),cls); }
 
-extern jlib_decl const LogMsgCategory MCdisaster;
-extern jlib_decl const LogMsgCategory MCuserError;
 #define MCerror MCuserError
-extern jlib_decl const LogMsgCategory MCoperatorError;
-extern jlib_decl const LogMsgCategory MCinternalError;
-extern jlib_decl const LogMsgCategory MCuserWarning;
 #define MCwarning MCuserWarning
-extern jlib_decl const LogMsgCategory MCoperatorWarning;
-extern jlib_decl const LogMsgCategory MCinternalWarning;
-// MCexception(e, cls) is now a convenient function to get a message category with its audience taken from an exception
-inline LogMsgCategory MCexception(IException * e, LogMsgClass cls = MSGCLS_error) { return LogMsgCategory((e)->errorAudience(),cls); }
-extern jlib_decl const LogMsgCategory MCuserProgress;
 #define MCprogress MCuserProgress
-extern jlib_decl const LogMsgCategory MCoperatorProgress;
-extern jlib_decl const LogMsgCategory MCdebugProgress;
-extern jlib_decl const LogMsgCategory MCdebugInfo;
-extern jlib_decl const LogMsgCategory MCstats;
-extern jlib_decl const LogMsgCategory MCoperatorInfo;
-extern jlib_decl const LogMsgCategory MClegacy;
 
 extern jlib_decl const LogMsgJobInfo unknownJob;