custom_log_space 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58dddf2fc7026b74b4f4afea69035a4a3c94f6d0b1e356a033c8c7368919d530
4
- data.tar.gz: '0826fdfdb8537d4935182fb05bb7155e5de1162a357fcdf333a89ede1c78900b'
3
+ metadata.gz: bb593f3ada3627f418dfe35b2b55ea90c1a697bea93122ecc2e134df75f3a22e
4
+ data.tar.gz: 9b67ad5d122d6eb55624342ef20612ac10b92d3d0c6a6177bf85293e513fc9af
5
5
  SHA512:
6
- metadata.gz: b6a1dcbf9c647fa2402aa11564af5875b0c6718ebf6ee59c8316cddd1a0072e27539ff9e8ea91a5602aced4625d7b098b18778b20b19a8fc2f9e22d977d63a16
7
- data.tar.gz: 938eb0064c5156508e350ec591a5bca3be50bb3955ec087753dd78fb8f8e90842dd290301492099272616c80800b00c6c2d665447b4a8b5ade3612857079db94
6
+ metadata.gz: '0738eaf07b4526d6d156874d1f5865e70c247ecdf085cd4bce305a04a80b15943a3431a83859a3cc3a4e9342e1b565b4e40d7b6a3be8457543bf2905e70344bf'
7
+ data.tar.gz: 945319f56b0e7055791bbcb877d7baa20685199d0f31d67f271e1c485c6cbe3c0de28bbfaf9c7298579814fc2ff288ed8d486eddf99a2e88bc083ab21f5cf833
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.5] - 2023-09-18
4
+ ### Changed
5
+ Modify so that only 10 files can be created
6
+
3
7
  ## [0.1.4] - 2023-09-15
4
8
  ### Changed
5
9
  Simplify the gem description
data/README.md CHANGED
@@ -51,8 +51,13 @@ user log % tree
51
51
  ```
52
52
 
53
53
  ## Retention Policy
54
+ To ensure optimal system performance and to prevent excessive disk usage, our logging system implements a strict retention policy:
54
55
 
55
- To prevent excessive disk usage, logs within the `date` directory are retained for only 2 days. Any logs older than this retention period will be automatically deleted, starting with the oldest. Ensure that you archive or backup logs if you need them for longer periods.
56
+ * Date Directory Limitation: Only up to 2 date directories can be created. Any additional date directory beyond this limit will lead to the automatic deletion of the oldest directory.
57
+
58
+ * File Limitation: Only up to 10 log files can be created within the date directory. Ensure to manage the number of logs being generated to stay within this limit.
59
+
60
+ Important: If you require logs to be retained for longer periods or need to keep more extensive records, make sure to archive or backup the necessary log files regularly to prevent any unwanted data loss.
56
61
 
57
62
  ## Ignoring Logs in Git
58
63
  If needed, add `/log/custom_log_space/*` to your `.gitignore` to ensure the logs aren't committed to your repository.
@@ -56,11 +56,22 @@ module CustomLogSpace
56
56
  yield(file) # Header or other info can be passed and written here
57
57
  file.puts(message)
58
58
  end
59
+
60
+ cleanup_old_log_files(directory_path)
59
61
  rescue SystemCallError, IOError => e
60
62
  error_prefix = e.is_a?(SystemCallError) ? "Error" : "IO Error"
61
63
  puts "#{error_prefix}: #{e.message}"
62
64
  end
63
65
 
66
+ def cleanup_old_log_files(directory_path)
67
+ log_files = Dir.entries(directory_path).select { |entry| entry =~ /\.log$/ }.sort
68
+ while log_files.size > 10
69
+ oldest_log_file = log_files.shift
70
+ path_to_remove = File.join(directory_path, oldest_log_file)
71
+ File.delete(path_to_remove)
72
+ end
73
+ end
74
+
64
75
  # rubocop:disable Metrics/AbcSize
65
76
  def write_header_information(file)
66
77
  return if Thread.current[:header_written]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomLogSpace
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_log_space
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - nishikawa1031
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-15 00:00:00.000000000 Z
11
+ date: 2023-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport