multilogger 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.bundle
7
+ *.so
8
+ *.dll
9
+ *.o
10
+ Makefile
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Burke Libbey, Thorkelson Consulting Ltd.
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/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "multilogger"
8
+ gem.summary = "Split Rails logging into multiple log files"
9
+ gem.description = "Multilogger pattern matches incoming log messages to decide which log file to write them to."
10
+ gem.email = "burke@burkelibbey.org"
11
+ gem.homepage = "http://github.com/burke/multilogger"
12
+ gem.authors = ["Burke Libbey"]
13
+ gem.files.include '{spec,lib}/**/*'
14
+ gem.add_dependency "activesupport"
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ begin
21
+ require 'rcov/rcovtask'
22
+ Rcov::RcovTask.new do |test|
23
+ test.libs << 'spec'
24
+ test.pattern = 'spec/**/*_spec.rb'
25
+ test.verbose = true
26
+ end
27
+ rescue LoadError
28
+ task :rcov do
29
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
30
+ end
31
+ end
32
+
33
+ require 'rake/rdoctask'
34
+ Rake::RDocTask.new do |rdoc|
35
+ if File.exist?('VERSION')
36
+ version = File.read('VERSION')
37
+ else
38
+ version = ""
39
+ end
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "multilogger #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,42 @@
1
+ # Extend rails' logger to support multiple targets.
2
+ # Patterns are added with `add_log`, then when a message is added to the log,
3
+ # it is checked against the patterns.
4
+ # example:
5
+ # logger = MultiLogger.new("log.txt")
6
+ # logger.add_log("Delayed::Job", "dj_log.txt")
7
+ class MultiLogger < ActiveSupport::BufferedLogger
8
+
9
+ # pattern can be either a String or a Regexp.
10
+ def add_log(pattern, target)
11
+ @extra_logs[pattern] = ActiveSupport::BufferedLogger.new(target)
12
+ return self # just so we can't accidentally grab the sub-log and do something stupid with it.
13
+ end
14
+
15
+ def initialize(target, level=DEBUG)
16
+ super(target, level)
17
+ @extra_logs = {}
18
+ end
19
+
20
+ alias __old_add add
21
+
22
+ def add(severity, message=nil, progname=nil, &block)
23
+ @extra_logs.keys.each do |pattern|
24
+ if message.match(pattern)
25
+ return @extra_logs[pattern].add(severity, message, progname, &block)
26
+ end
27
+ end
28
+ __old_add(severity, message, progname, &block)
29
+ end
30
+
31
+ # Set a few methods to also call on all the defined sub-logs.
32
+ # This is handled a little inefficiently, but these won't be called often.
33
+ [:auto_flush, :buffer, :clear_buffer, :silence, :auto_flushing=, :flush, :close].each do |method|
34
+ alias_method "__old_#{method}".to_sym, method
35
+ define_method method do |*args|
36
+ @extra_logs.values.each{|e|e.method(method).call(*args)}
37
+ method("__old_#{method}").call(*args)
38
+ end
39
+ end
40
+ protected :auto_flush, :buffer, :clear_buffer
41
+
42
+ end
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{multilogger}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Burke Libbey"]
12
+ s.date = %q{2010-01-13}
13
+ s.description = %q{Multilogger pattern matches incoming log messages to decide which log file to write them to.}
14
+ s.email = %q{burke@burkelibbey.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/multilogger.rb",
24
+ "multilogger.gemspec"
25
+ ]
26
+ s.homepage = %q{http://github.com/burke/multilogger}
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubygems_version = %q{1.3.5}
30
+ s.summary = %q{Split Rails logging into multiple log files}
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
38
+ else
39
+ s.add_dependency(%q<activesupport>, [">= 0"])
40
+ end
41
+ else
42
+ s.add_dependency(%q<activesupport>, [">= 0"])
43
+ end
44
+ end
45
+
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multilogger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Burke Libbey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-13 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Multilogger pattern matches incoming log messages to decide which log file to write them to.
26
+ email: burke@burkelibbey.org
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ files:
34
+ - .gitignore
35
+ - LICENSE
36
+ - Rakefile
37
+ - VERSION
38
+ - lib/multilogger.rb
39
+ - multilogger.gemspec
40
+ has_rdoc: true
41
+ homepage: http://github.com/burke/multilogger
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Split Rails logging into multiple log files
68
+ test_files: []
69
+