diff --git a/helm/hpcc/templates/_helpers.tpl b/helm/hpcc/templates/_helpers.tpl index eed1336e2b7..ff49d619c4b 100644 --- a/helm/hpcc/templates/_helpers.tpl +++ b/helm/hpcc/templates/_helpers.tpl @@ -689,13 +689,13 @@ Check that the storage and spill planes for a component exist Add command for a component */}} {{- define "hpcc.componentCommand" -}} - {{- if .me.valgrind -}} +{{- if .me.valgrind -}} valgrind - {{- else if (include "hpcc.hasPlaneForCategory" (dict "root" .root "category" "debug")) -}} +{{- else if (include "hpcc.hasPlaneForCategory" (dict "root" .root "category" "debug")) -}} check_executes - {{- else -}} +{{- else -}} {{ .process }} - {{- end }} +{{- end }} {{- end -}} {{/* @@ -713,9 +713,12 @@ Add extra args for a component {{- $debugPlane := .me.debugPlane | default (include "hpcc.getFirstPlaneForCategory" (dict "root" .root "category" "debug")) -}} {{- include "hpcc.checkPlaneExists" (dict "root" .root "planeName" $debugPlane) -}} {{- $prefix := include "hpcc.getPlanePrefix" (dict "root" .root "planeName" $debugPlane) -}} - {{- if or (and (hasKey .me "expert") .me.expert.alwaysPostMortem) (and (hasKey .root.Values.global "expert") .root.Values.global.expert.alwaysPostMortem) -}} + {{- $meExpert := .me.expert | default dict -}} + {{- $globalExpert := .root.Values.global.expert | default dict -}} + {{- $alwaysPostMortem := (hasKey $meExpert "alwaysPostMortem") | ternary $meExpert.alwaysPostMortem ($globalExpert.alwaysPostMortem | default false) -}} + {{- if $alwaysPostMortem -}} "-a",{{ "\n" }} - {{- end -}} + {{- end -}} "-d", {{ $prefix }}, "--", {{ .process | quote }}, @@ -1674,7 +1677,10 @@ args: {{- include "hpcc.checkPlaneExists" (dict "root" .root "planeName" $debugPlane) -}} {{- $prefix := include "hpcc.getPlanePrefix" (dict "root" .root "planeName" $debugPlane) -}} {{- $pmd_always_opt := "" -}} - {{- if or (and (hasKey .me "expert") .me.expert.alwaysPostMortem) (and (hasKey .root.Values.global "expert") .root.Values.global.expert.alwaysPostMortem) -}} + {{- $globalExpert := .root.Values.global.expert | default dict -}} + {{- $meExpert := .me.expert | default dict -}} + {{- $alwaysPostMortem := (hasKey $meExpert "alwaysPostMortem") | ternary $meExpert.alwaysPostMortem ($globalExpert.alwaysPostMortem | default false) -}} + {{- if $alwaysPostMortem -}} {{- $pmd_always_opt = "-a " -}} {{- end -}} {{- $_ := set $check_cmd "command" (printf "check_executes %s-d %s -- %s" $pmd_always_opt $prefix .command) -}} diff --git a/system/jlib/jlog.cpp b/system/jlib/jlog.cpp index 8e44015fb6d..ba237000813 100644 --- a/system/jlib/jlog.cpp +++ b/system/jlib/jlog.cpp @@ -671,6 +671,83 @@ StringBuffer & LogMsg::toStringTable(StringBuffer & out, unsigned fields) const return out; } +StringBuffer & LogMsg::toStringCSV(StringBuffer & out, unsigned fields) const +{ + if(fields & MSGFIELD_msgID) + out.appendf("%08X,", sysInfo.queryMsgID()); + out.ensureCapacity(LOG_MSG_FORMAT_BUFFER_LENGTH); + if(fields & MSGFIELD_audience) + out.appendf("%s,", LogMsgAudienceToFixString(category.queryAudience())); + if(fields & MSGFIELD_class) + out.appendf("%s,", LogMsgClassToFixString(category.queryClass())); + if(fields & MSGFIELD_detail) + out.appendf("%d,", category.queryDetail()); + if(fields & MSGFIELD_timeDate) + { + time_t timeNum = sysInfo.queryTime(); + char timeString[12]; + struct tm timeStruct; + localtime_r(&timeNum, &timeStruct); + if(fields & MSGFIELD_date) + { + strftime(timeString, 12, "%Y-%m-%d,", &timeStruct); + out.append(timeString); + } + if(fields & MSGFIELD_microTime) + { + out.appendf("%02d:%02d:%02d.%06d,", timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec, sysInfo.queryUSecs()); + } + else if(fields & MSGFIELD_milliTime) + { + out.appendf("%02d:%02d:%02d.%03d,", timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec, sysInfo.queryUSecs()/1000); + } + else if(fields & MSGFIELD_time) + { + strftime(timeString, 12, "%H:%M:%S,", &timeStruct); + out.append(timeString); + } + } + if(fields & MSGFIELD_process) + out.appendf("%d,",sysInfo.queryProcessID()); + if(fields & MSGFIELD_thread) + out.appendf("%d,",sysInfo.queryThreadID()); + if(fields & MSGFIELD_session) + { + if(sysInfo.querySessionID() == UnknownSession) + out.append("unknown"); + else + out.appendf("%" I64F "u,", sysInfo.querySessionID()); + } + if(fields & MSGFIELD_node) + { + sysInfo.queryNode()->getUrlStr(out).append(','); + } + if(fields & MSGFIELD_job) + { + out.appendf("%s,", jobInfo.queryJobIDStr()); + } + if(fields & MSGFIELD_user) + { + if(jobInfo.queryUserID() == UnknownUser) + out.append("unknown,"); + else + out.appendf("%" I64F "u,", jobInfo.queryUserID()); + } + if (fields & MSGFIELD_quote) + out.append('"'); + if (fields & MSGFIELD_prefix) + out.append(msgPrefix(category.queryClass())); + if((fields & MSGFIELD_code) && (msgCode != NoLogMsgCode)) + out.append(msgCode).append(": ").append(text.str()); + else + out.append(text.str()); + if (fields & MSGFIELD_quote) + out.append('"'); + out.append('\n'); + return out; +} + + StringBuffer & LogMsg::toStringTableHead(StringBuffer & out, unsigned fields) { loggingFieldColumns.generateHeaderRow(out, fields, false).append("\n\n"); @@ -879,7 +956,7 @@ void CategoryLogMsgFilter::reset() void HandleLogMsgHandlerTable::handleMessage(const LogMsg & msg) { CriticalBlock block(crit); - msg.toStringTable(curMsgText.clear(), messageFields); + msg.toStringCSV(curMsgText.clear(), messageFields); fputs(curMsgText.str(), handle); } @@ -976,7 +1053,7 @@ FileLogMsgHandler::~FileLogMsgHandler() void FileLogMsgHandlerTable::handleMessage(const LogMsg & msg) { CriticalBlock block(crit); - msg.toStringTable(curMsgText.clear(), messageFields); + msg.toStringCSV(curMsgText.clear(), messageFields); fputs(curMsgText.str(), handle); if(flushes) fflush(handle); diff --git a/system/jlib/jlog.hpp b/system/jlib/jlog.hpp index cfb7692af02..b2f376e6ae2 100644 --- a/system/jlib/jlog.hpp +++ b/system/jlib/jlog.hpp @@ -588,6 +588,7 @@ class jlib_decl LogMsg : public CInterface StringBuffer & toStringXML(StringBuffer & out, unsigned fields) const; StringBuffer & toStringJSON(StringBuffer & out, unsigned fields) const; StringBuffer & toStringTable(StringBuffer & out, unsigned fields) const; + StringBuffer & toStringCSV(StringBuffer & out, unsigned fields) const; static StringBuffer & toStringTableHead(StringBuffer & out, unsigned fields); static void fprintTableHead(FILE * handle, unsigned fields); inline const LogMsgCategory queryCategory() const { return category; } diff --git a/system/jlib/jlog.ipp b/system/jlib/jlog.ipp index bfd06cb5f21..0c4040564a5 100644 --- a/system/jlib/jlog.ipp +++ b/system/jlib/jlog.ipp @@ -587,9 +587,9 @@ public: printHeader = false; } if (currentLogFields) // If appending to existing log file, use same format as existing - msg.toStringTable(curMsgText.clear(), currentLogFields); + msg.toStringCSV(curMsgText.clear(), currentLogFields); else - msg.toStringTable(curMsgText.clear(), messageFields); + msg.toStringCSV(curMsgText.clear(), messageFields); fputs(curMsgText.str(), handle); if(flushes) fflush(handle);