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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -1
- data/lib/custom_log_space/base_helper/log_writer.rb +11 -0
- data/lib/custom_log_space/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb593f3ada3627f418dfe35b2b55ea90c1a697bea93122ecc2e134df75f3a22e
|
4
|
+
data.tar.gz: 9b67ad5d122d6eb55624342ef20612ac10b92d3d0c6a6177bf85293e513fc9af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0738eaf07b4526d6d156874d1f5865e70c247ecdf085cd4bce305a04a80b15943a3431a83859a3cc3a4e9342e1b565b4e40d7b6a3be8457543bf2905e70344bf'
|
7
|
+
data.tar.gz: 945319f56b0e7055791bbcb877d7baa20685199d0f31d67f271e1c485c6cbe3c0de28bbfaf9c7298579814fc2ff288ed8d486eddf99a2e88bc083ab21f5cf833
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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]
|
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
|
+
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-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|