abs007 commented on code in PR #9210:
URL: https://github.com/apache/apisix/pull/9210#discussion_r1156859739
##########
apisix/plugins/log-rotate.lua:
##########
@@ -299,23 +313,34 @@ local function rotate()
end
if now_time >= rotate_time then
- local files = {DEFAULT_ACCESS_LOG_FILENAME, DEFAULT_ERROR_LOG_FILENAME}
+ local new_access_log, new_error_log = get_custom_logfile_name()
+
+ local access_log_filename = new_access_log or
DEFAULT_ACCESS_LOG_FILENAME
+ local error_log_filename = new_error_log or DEFAULT_ERROR_LOG_FILENAME
+
+ local files = {access_log_filename, error_log_filename}
+
rotate_file(files, now_time, max_kept)
-- reset rotate time
rotate_time = rotate_time + interval
elseif max_size > 0 then
- local access_log_file_size =
file_size(default_logs[DEFAULT_ACCESS_LOG_FILENAME].file)
- local error_log_file_size =
file_size(default_logs[DEFAULT_ERROR_LOG_FILENAME].file)
+ local new_access_log, new_error_log = get_custom_logfile_name()
+
+ local access_log_filename = new_access_log or
DEFAULT_ACCESS_LOG_FILENAME
+ local error_log_filename = new_error_log or DEFAULT_ERROR_LOG_FILENAME
+
+ local access_log_file_size =
file_size(default_logs[access_log_filename].file)
+ local error_log_file_size =
file_size(default_logs[error_log_filename].file)
local files = core.table.new(2, 0)
if access_log_file_size >= max_size then
- core.table.insert(files, DEFAULT_ACCESS_LOG_FILENAME)
+ core.table.insert(files, access_log_filename)
end
if error_log_file_size >= max_size then
- core.table.insert(files, DEFAULT_ERROR_LOG_FILENAME)
+ core.table.insert(files, error_log_filename)
Review Comment:
Do you mean the `_M.init()` function?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]