|
@@ -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
|
|
|
{
|