From 19eef4a334ebad46b8b3467ff1e4e224f0917dbc Mon Sep 17 00:00:00 2001 From: Wouter R Date: Wed, 16 Mar 2016 22:54:21 +0100 Subject: [PATCH] Include rotated log files in 'info/logfiles' API endpoint. --- src/rest/api/api_info.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_info.lua b/src/rest/api/api_info.lua index f5283c1..f0281a9 100644 --- a/src/rest/api/api_info.lua +++ b/src/rest/api/api_info.lua @@ -23,6 +23,8 @@ local DEFAULT_WIFIBOX_LOG_FILENAME = 'wifibox.log' local DEFAULT_WIFIBOX_LOG_FILE = TMP_DIR .. '/' .. DEFAULT_WIFIBOX_LOG_FILENAME local WIFIBOX_STDOUT_LOG_FILENAME = 'wifibox.stdout.log' local WIFIBOX_STDOUT_LOG_FILE = TMP_DIR .. '/' .. WIFIBOX_STDOUT_LOG_FILENAME +local ROTATED_LOGS_DIRNAME = 'wifibox-rotated' +local ROTATED_LOGS_DIR = TMP_DIR .. '/' .. ROTATED_LOGS_DIRNAME local MOD_ABBR = "AINF" local SYSLOG_FILENAME = 'syslog' @@ -72,12 +74,15 @@ function M.logfiles(request, response) --[[ create temporary files ]]-- - -- copy wifibox API-script log + -- copy wifibox API-script (firmware) log rv,sig,code = redirectedExecute('cp ' .. wifiboxLogFilePath .. ' ' .. LOG_COLLECT_DIR) - -- copy d3dapi script stdout/stderr log + -- copy d3dapi script stdout/stderr (fallback) log rv,sig,code = redirectedExecute('cp ' .. WIFIBOX_STDOUT_LOG_FILE .. ' ' .. LOG_COLLECT_DIR) + -- copy rotated firmware and print3d logs + rv,sig,code = redirectedExecute('cp -r ' .. ROTATED_LOGS_DIR .. ' ' .. LOG_COLLECT_DIR) + -- capture syslog rv,sig,code = os.execute('logread > ' .. LOG_COLLECT_DIR .. '/' .. SYSLOG_FILENAME) @@ -142,12 +147,17 @@ function M.logfiles(request, response) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/config/*') rv,msg = lfs.rmdir(LOG_COLLECT_DIR .. '/config') + -- Note: this assumes the rotated logs directory does not contain subdirectories + rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. ROTATED_LOGS_DIRNAME .. '/*') + rv,msg = lfs.rmdir(LOG_COLLECT_DIR .. '/' .. ROTATED_LOGS_DIRNAME) + rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. USB_DIRTREE_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. DISKFREE_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. MOUNTS_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. MEMINFO_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. PROCESS_LIST_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. SYSLOG_FILENAME) + rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. WIFIBOX_STDOUT_LOG_FILENAME) rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. wifiboxLogFileName) rv,msg = lfs.rmdir(LOG_COLLECT_DIR)