rails-pretty-logger 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/rails/pretty/logger/rails_logger.rb +13 -12
- data/lib/rails/pretty/logger/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0642bfe00ac5163430b1553c5aba82cfbcf2c534
|
4
|
+
data.tar.gz: edd1d062bab8ddc88a42383eb422eea973cda025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d71dc9e529b1935692ec50b76b30ac00399495f94b474d4327debd7ae03cbcd28a1a5adea3cba2c7701821c95fcc1a474fff176fb647781d48a97abc28e1ca3a
|
7
|
+
data.tar.gz: 767dcbb3d351af27d56eabd94ee5d38fd495372ca5c51b34a2031013ff60c90c42d7abfc8454cef7574645e76d12bcac267f5f4d5e00f830970b2eb69c7b0a5b
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Rails::Pretty::Logger
|
2
|
-
Pretty Logger is a logging framework which
|
2
|
+
Pretty Logger is a logging framework which helps for checking logs from page, with PrettyLogger.highlight method you can easily spot what you seek.If you want to perform hourly log rotation Override logger class with Pretty logger, with file_count parameter kept files can be limited as you wish.
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
visit http://your-webpage/rails-pretty-logger/dashboards/ then choose your
|
5
|
+
visit http://your-webpage/rails-pretty-logger/dashboards/ then choose your log file, search with date range.
|
6
6
|
![](log_file.gif)
|
7
7
|
|
8
8
|
#### How to use debug Highlighter
|
@@ -50,7 +50,6 @@ Mount the engine in your config/routes.rb:
|
|
50
50
|
mount Rails::Pretty::Logger::Engine => "/rails-pretty-logger"
|
51
51
|
```
|
52
52
|
|
53
|
-
|
54
53
|
## Contributing
|
55
54
|
|
56
55
|
1. [Fork][fork] the [official repository][repo].
|
@@ -107,7 +107,6 @@ module Rails::Pretty::Logger
|
|
107
107
|
|
108
108
|
age_file = "#{@filename}.#{suffix}"
|
109
109
|
|
110
|
-
|
111
110
|
if FileTest.exist?(age_file)
|
112
111
|
# try to avoid filename crash caused by Timestamp change.
|
113
112
|
idx = 0
|
@@ -121,20 +120,12 @@ module Rails::Pretty::Logger
|
|
121
120
|
|
122
121
|
#delete old files
|
123
122
|
log_files = Dir[ File.join(Rails.root, 'log', 'hourly') + "/#{suffix_year}/**/*"].reject {|fn| File.directory?(fn) }
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
while (log_files_length > @file_count) do
|
128
|
-
arr = []
|
129
|
-
log_files.each { |x| arr.push(File.ctime(x).to_i) }
|
130
|
-
|
123
|
+
while (log_files.length > @file_count) do
|
124
|
+
arr = log_files.reduce([]){|memo, log_file| memo << File.ctime(log_file).to_i}
|
131
125
|
file_index = arr.index(arr.min)
|
132
|
-
|
133
126
|
file_path = log_files[file_index]
|
134
|
-
|
135
|
-
|
127
|
+
delete_old_file(file_path)
|
136
128
|
log_files = Dir[ File.join(Rails.root, 'log', 'hourly') + "/#{suffix_year}/**/*"].reject {|fn| File.directory?(fn) }
|
137
|
-
log_files_length = log_files.length
|
138
129
|
end
|
139
130
|
|
140
131
|
@dev.close rescue nil
|
@@ -147,6 +138,16 @@ module Rails::Pretty::Logger
|
|
147
138
|
@dev = create_logfile(@filename)
|
148
139
|
return true
|
149
140
|
end
|
141
|
+
|
142
|
+
def delete_old_file(file_path)
|
143
|
+
day_dir = File.dirname(file_path)
|
144
|
+
month_dir = File.expand_path("..",day_dir)
|
145
|
+
year_dir = File.expand_path("../..",day_dir)
|
146
|
+
File.delete(file_path) if File.exist?(file_path)
|
147
|
+
Dir.rmdir(day_dir) if Dir.empty?(day_dir)
|
148
|
+
Dir.rmdir(month_dir) if month_dir.empty?
|
149
|
+
Dir.rmdir(year_dir) if year_dir.empty?
|
150
|
+
end
|
150
151
|
end
|
151
152
|
|
152
153
|
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.1
|
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-04-
|
12
|
+
date: 2019-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -59,8 +59,8 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.6'
|
62
|
-
description:
|
63
|
-
|
62
|
+
description: 'Check and search your logs from page, hightlight it to spot easily,
|
63
|
+
add hourly rotation if you wish. '
|
64
64
|
email:
|
65
65
|
- cbaykam@gmail.com
|
66
66
|
- mehmetcelik4@gmail.com
|