Skip to content

Commit

Permalink
Merge pull request #2196 from AllenInstitute/bugfix/2196-fix_logfile_…
Browse files Browse the repository at this point in the history
…output

Fix Move logfile splitting / fix special case
  • Loading branch information
t-b authored Aug 6, 2024
2 parents 6ca0326 + e54c73c commit c72f27f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 0 additions & 1 deletion Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,6 @@ Function DAP_LockDevice(string win)

HW_RegisterDevice(deviceLocked, hardwareType, deviceID)
if(ItemsInList(GetListOfLockedDevices()) == 1)
ArchiveLogFilesOnceAndKeepMonth()
DAP_LoadBuiltinStimsets()
GetPxPVersion()
SetupBackgroundTasks()
Expand Down
18 changes: 18 additions & 0 deletions Packages/MIES/MIES_IgorHooks.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,29 @@ static Function IgorBeforeQuitHook(unsavedExp, unsavedNotebooks, unsavedProcedur
return 0
End

static Function ShowQuitMessage()

variable xPos, yPos

GetWindow kwFrameInner, wSizeDC
xPos = (V_right - V_left) / 2 - 400
yPos = (V_bottom - V_top) / 3
NewPanel/K=1/W=(xPos, yPos, xPos + 800, yPos + 75) as "Just a moment"
ModifyPanel fixedSize=0
TitleBox title_Counts, pos={0.00, 0.00}, size={800, 90.00}, title="Quitting MIES..."
TitleBox title_Counts, font="Courier New", fSize=72, frame=0, fStyle=1
TitleBox title_Counts, anchor=MC, fixedSize=1
DoUpdate
End

static Function IgorQuitHook(igorApplicationNameStr)
string igorApplicationNameStr

LOG_AddEntry(PACKAGE_MIES, "start")

ShowQuitMessage()
zeromq_stop()
ArchiveLogFilesOnceAndKeepMonth()
IH_Cleanup()

LOG_AddEntry(PACKAGE_MIES, "end")
Expand Down
7 changes: 5 additions & 2 deletions Packages/MIES/MIES_MiesUtilities_Logging.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Function/S GetITCXOP2Logfile()
return PS_GetSettingsFolder(PACKAGE_MIES) + ":ITCXOP2:Log.jsonl"
End

/// @brief Filters log file entries by data, returns a null wave if no entries were found
Function [WAVE/T filtered, variable lastIndex] FilterByDate(WAVE/T entries, variable first, variable last)

variable firstIndex
Expand All @@ -35,7 +36,7 @@ Function [WAVE/T filtered, variable lastIndex] FilterByDate(WAVE/T entries, vari

firstIndex = FindFirstLogEntryElementByDate(entries, first)
lastIndex = FindLastLogEntryElementByDate(entries, last)
if(lastIndex < firstIndex)
if(IsNaN(firstIndex) || IsNaN(lastIndex) || lastIndex < firstIndex)
return [$"", NaN]
endif

Expand Down Expand Up @@ -148,7 +149,9 @@ Function ArchiveLogFilesOnceAndKeepMonth()
WAVE/Z/T logData = LoadTextFileToWave(file, LOG_FILE_LINE_END)
if(WaveExists(logData))
[WAVE/T partData, lastIndex] = FilterByDate(logData, firstDate, lastDate)
ArchiveLogFile(logData, file, lastIndex)
if(WaveExists(partData))
ArchiveLogFile(logData, file, lastIndex)
endif
endif
endfor
End
Expand Down

0 comments on commit c72f27f

Please sign in to comment.