rails-pretty-logger 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/rails/pretty/logger/version.rb +1 -1
- data/lib/tasks/rails/pretty/logger_tasks.rake +33 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5bfe4987b4c810ca8bdd90b8722914ea57c0e7
|
4
|
+
data.tar.gz: 86603f1a83fea878766fbfe55a2aa41411b6bef5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe8e0a1846597944e9f35628d29ae3ce55fe09ebc7ee9cc29797c0f07b2f538fe11a7048c53e60c109b1ab405d2b8636dd8b0333623d829283d279a1d31eae70
|
7
|
+
data.tar.gz: 436178bd2a9eb9b40369833be13ec39171468b7360772a183d2610e4d07ff97d1f163844255b04033ad508a1c2318864e933a442d38637599e05bedbbc0facf4
|
data/README.md
CHANGED
@@ -28,6 +28,15 @@ config.logger = logger_file
|
|
28
28
|
```
|
29
29
|
![](hour.gif)
|
30
30
|
|
31
|
+
#### Split your old logs by hourly
|
32
|
+
|
33
|
+
If you want split your old log files by hourly you can use this rake task below at terminal
|
34
|
+
|
35
|
+
argument takes what will be new files names start with, and with the second one will take the full path of your log file which will be splitted
|
36
|
+
|
37
|
+
for bash usage ```rake app:split_log["new_log_file_name","/path/to/your/log.file"]```
|
38
|
+
for zch usage ```noglob rake app:split_log["new_log_file_name","/path/to/your/log.file"]```
|
39
|
+
|
31
40
|
## Installation
|
32
41
|
Add this line to your application's Gemfile:
|
33
42
|
|
@@ -1,4 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
desc "Split log with hourly"
|
2
|
+
task :split_log, [:log_name, :log_path] do |t, arg|
|
3
|
+
|
4
|
+
start = false
|
5
|
+
new_path = nil
|
6
|
+
file_path = nil
|
7
|
+
|
8
|
+
def get_date(line)
|
9
|
+
if line.include?("Started")
|
10
|
+
date_index = line.index("at ")
|
11
|
+
date = line[date_index .. date_index + 18]
|
12
|
+
date.to_datetime
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
IO.foreach(arg[:log_path]) do |line|
|
17
|
+
date = get_date(line) rescue nil
|
18
|
+
if date
|
19
|
+
start = true
|
20
|
+
new_path = File.join(Rails.root, 'log', 'hourly', date.strftime('%Y'), date.strftime('%m'), date.strftime('%d'))
|
21
|
+
FileUtils.mkdir_p new_path unless File.directory?(new_path)
|
22
|
+
file_path = "#{new_path}/#{arg[:log_name]}.log.#{date.strftime('%Y%m%d_%H00')}"
|
23
|
+
File.open(file_path, 'a') do |file|
|
24
|
+
file << line
|
25
|
+
end
|
26
|
+
elsif start
|
27
|
+
File.open(file_path, 'a') do |file|
|
28
|
+
file << line
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
puts "It's done"
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-pretty-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cem
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-05-
|
12
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|