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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7acf4d8e8fac238681470c78bf56b504062f7244
4
- data.tar.gz: 67b3952e809cde6091e20277e6532bff1b6ffc90
3
+ metadata.gz: 0642bfe00ac5163430b1553c5aba82cfbcf2c534
4
+ data.tar.gz: edd1d062bab8ddc88a42383eb422eea973cda025
5
5
  SHA512:
6
- metadata.gz: b85f59676bb1e5c5fcdcbe3f1559418d0f1f6ba3c7bb9292849e93e1bc5536e28c5cedf782d831bc26b1fa1de0ec6e97f80449b02178809d235270836f4ad249
7
- data.tar.gz: ca0b8c8fbfd2c1002b1680763eed91129e6a1f5299f013e5873ac95b00191949b8a14ec52092a2d3ad0b156de65aecb8cdaa83eaa77c291310d4a0d66ce46cfb
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 can be checked from webpage, and also you can also debug easily with highlight method. You can also override logger class woth Pretty logger so you can keep hourly logs, which can be limited as you wish.
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 environment, which you want to check and also you can set date range for narrowing down your logs.
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
- log_files_length = log_files.length
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
- File.delete(file_path) if File.exist?(file_path)
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
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Pretty
3
3
  module Logger
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
6
6
  end
7
7
  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.0
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-11 00:00:00.000000000 Z
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: " With Pretty logger, can check your logs from web page, can also easily
63
- check your logs with hourly rotation "
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