19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jfrog/saas/log/filemanager.rb', line 19
def purge_data
Dir["#{ConfigHandler.instance.log_config.target_log_path}/**/*.log"].reject { |i| File.directory?(i) }.each do |file_name|
created_time = File.ctime(file_name)
diff_days = created_time.to_date.mjd - (Date.today - ConfigHandler.instance.log_config.log_file_retention_days).mjd
MessageUtils.instance.log_message(MessageUtils::PURGE_RETAIN_DAYS_FOR_FILE, { "param1": file_name.to_s,
"param2": diff_days.to_s,
"#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_INFO,
"#{MessageUtils::SOLUTION}": FileManager::PROCESS_NAME } )
next unless diff_days.negative?
File.delete(file_name)
MessageUtils.instance.log_message(MessageUtils::PURGE_SUCCESS_FOR_FILE, { "param1": file_name.to_s,
"#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_INFO,
"#{MessageUtils::SOLUTION}": FileManager::PROCESS_NAME } )
end
end
|