Skip to content

Commit

Permalink
HPCC-30413 review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Oct 3, 2023
1 parent f6d4cb2 commit 7891c69
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 11 deletions.
20 changes: 13 additions & 7 deletions helm/hpcc/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

{{/*
Expand All @@ -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 }},
Expand Down Expand Up @@ -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) -}}
Expand Down
81 changes: 79 additions & 2 deletions system/jlib/jlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions system/jlib/jlog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions system/jlib/jlog.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7891c69

Please sign in to comment.