rails_log_autotruncator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/rails_log_autotruncator.rb +28 -0
- data/spec/rails_log_autotruncator_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +97 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Dmitry Plashchynski
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= rails_log_autotruncator
|
2
|
+
|
3
|
+
rails_log_autotruncator is a simple patch for ActiveSupport::BufferedLogger that limits a log file size. Use it if you just don't want your rails project development log file becomes large.
|
4
|
+
|
5
|
+
== Contributing to rails_log_autotruncator
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Dmitry Plashchynski. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
7
|
+
gem.name = "rails_log_autotruncator"
|
8
|
+
gem.homepage = "http://github.com/plashchynski/rails_log_autotruncator"
|
9
|
+
gem.license = "MIT"
|
10
|
+
gem.summary = %Q{The tool for automatically rotating and truncating a rails development log file}
|
11
|
+
gem.description = %Q{rails_log_autotruncator is a simple patch for ActiveSupport::BufferedLogger that limits a log file size. Use it if you just don't want your rails project development log file becomes large.}
|
12
|
+
gem.email = "plashchynski@gmail.com"
|
13
|
+
gem.authors = ["Dmitry Plashchynski"]
|
14
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
15
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
16
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
17
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
18
|
+
# gem.add_development_dependency "rspec", "~> 2.3.0"
|
19
|
+
gem.add_development_dependency "bundler", "~> 1.0.0"
|
20
|
+
gem.add_development_dependency "jeweler", "~> 1.5.2"
|
21
|
+
gem.add_development_dependency "rcov", ">= 0"
|
22
|
+
end
|
23
|
+
Jeweler::RubygemsDotOrgTasks.new
|
24
|
+
|
25
|
+
# require 'rspec/core'
|
26
|
+
# require 'rspec/core/rake_task'
|
27
|
+
# RSpec::Core::RakeTask.new(:spec) do |spec|
|
28
|
+
# spec.pattern = FileList['spec/**/*_spec.rb']
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# RSpec::Core::RakeTask.new(:rcov) do |spec|
|
32
|
+
# spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
# spec.rcov = true
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "rails_log_autotruncator #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rails_log_autotruncator'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ActiveSupport
|
2
|
+
class BufferedLogger
|
3
|
+
def flush
|
4
|
+
@guard.synchronize do
|
5
|
+
unless buffer.empty?
|
6
|
+
old_buffer = buffer
|
7
|
+
all_content = StringIO.new
|
8
|
+
old_buffer.each do |content|
|
9
|
+
all_content << content
|
10
|
+
end
|
11
|
+
@log.write(all_content.string)
|
12
|
+
end
|
13
|
+
|
14
|
+
if @log.size > 1_000_000
|
15
|
+
log = @log.path
|
16
|
+
@log.close
|
17
|
+
File.atomic_write(log) do |file|
|
18
|
+
file.write(IO.readlines(log)[-1000..-1].join)
|
19
|
+
end
|
20
|
+
@log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
|
21
|
+
@log.sync = true
|
22
|
+
end
|
23
|
+
|
24
|
+
clear_buffer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'rails_log_autotruncator'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_log_autotruncator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dmitry Plashchynski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-10 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: jeweler
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.5.2
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rcov
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
description: rails_log_autotruncator is a simple patch for ActiveSupport::BufferedLogger that limits a log file size. Use it if you just don't want your rails project development log file becomes large.
|
49
|
+
email: plashchynski@gmail.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.rdoc
|
57
|
+
files:
|
58
|
+
- .document
|
59
|
+
- .rspec
|
60
|
+
- LICENSE.txt
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- VERSION
|
64
|
+
- init.rb
|
65
|
+
- lib/rails_log_autotruncator.rb
|
66
|
+
- spec/rails_log_autotruncator_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
homepage: http://github.com/plashchynski/rails_log_autotruncator
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.7.2
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: The tool for automatically rotating and truncating a rails development log file
|
95
|
+
test_files:
|
96
|
+
- spec/rails_log_autotruncator_spec.rb
|
97
|
+
- spec/spec_helper.rb
|