trinidad_logging_extension 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ == 0.1.0 (??)
2
+
3
+ * First release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David Calavera
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 ADDED
@@ -0,0 +1,39 @@
1
+ Trinidad Logging Extension
2
+ ==========================
3
+
4
+ # DESCRIPTION
5
+
6
+ Extension to enhance the Trinidad's logging based on Apache Log4j(http://logging.apache.org/log4j).
7
+
8
+ # INSTALLATION
9
+
10
+ jruby -S gem install trinidad_logging_extension
11
+
12
+ # CONFIGURATION
13
+
14
+ The extension needs a configuration file for log4j. The default path for
15
+ this file is 'config/trinidad-logging.properties' but it can be overrided
16
+ into the Trinidad's configuration file.
17
+
18
+ To enable the extension add this to your trinidad.yml:
19
+
20
+ ---
21
+ extensions:
22
+ logging:
23
+ config: other_properties.properties # This field is optional
24
+
25
+ This is an example of configuration file extracted from the Tomcat's documentation:
26
+
27
+ log4j.rootLogger=INFO, R
28
+ log4j.appender.R=org.apache.log4j.RollingFileAppender
29
+ log4j.appender.R.File=log/trinidad.log
30
+ log4j.appender.R.MaxFileSize=10MB
31
+ log4j.appender.R.MaxBackupIndex=10
32
+ log4j.appender.R.layout=org.apache.log4j.PatternLayout
33
+ log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
34
+
35
+ You can find further information on how to write your own extension in the wiki: http://wiki.github.com/calavera/trinidad/extensions
36
+
37
+ # Copyright
38
+
39
+ Copyright (c) 2010 David Calavera. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,147 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :spec
47
+
48
+ require 'spec/rake/spectask'
49
+ Spec::Rake::SpecTask.new(:spec) do |spec|
50
+ spec.libs << 'lib' << 'spec'
51
+ spec.spec_opts = ['--options', 'spec/spec.opts']
52
+ spec.spec_files = FileList['spec/**/*_spec.rb']
53
+ end
54
+
55
+
56
+ desc "Generate RCov test coverage and open in your browser"
57
+ task :coverage do
58
+ require 'rcov'
59
+ sh "rm -fr coverage"
60
+ sh "rcov test/test_*.rb"
61
+ sh "open coverage/index.html"
62
+ end
63
+
64
+ require 'rake/rdoctask'
65
+ Rake::RDocTask.new do |rdoc|
66
+ rdoc.rdoc_dir = 'rdoc'
67
+ rdoc.title = "#{name} #{version}"
68
+ rdoc.rdoc_files.include('README*')
69
+ rdoc.rdoc_files.include('lib/**/*.rb')
70
+ end
71
+
72
+ desc "Open an irb session preloaded with this library"
73
+ task :console do
74
+ sh "irb -rubygems -r ./lib/#{name}.rb"
75
+ end
76
+
77
+ #############################################################################
78
+ #
79
+ # Custom tasks (add your own tasks here)
80
+ #
81
+ #############################################################################
82
+
83
+
84
+
85
+ #############################################################################
86
+ #
87
+ # Packaging tasks
88
+ #
89
+ #############################################################################
90
+
91
+ task :release => :build do
92
+ unless `git branch` =~ /^\* master$/
93
+ puts "You must be on the master branch to release!"
94
+ exit!
95
+ end
96
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
97
+ sh "git tag v#{version}"
98
+ sh "git push origin master"
99
+ sh "git push v#{version}"
100
+ sh "gem push pkg/#{name}-#{version}.gem"
101
+ end
102
+
103
+ task :build => 'gemspec' do
104
+ sh "mkdir -p pkg"
105
+ sh "gem build #{gemspec_file}"
106
+ sh "mv #{gem_file} pkg"
107
+ end
108
+
109
+ task :gemspec => :validate do
110
+ # read spec file and split out manifest section
111
+ spec = File.read(gemspec_file)
112
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
113
+
114
+ # replace name version and date
115
+ replace_header(head, :name)
116
+ replace_header(head, :version)
117
+ replace_header(head, :date)
118
+ #comment this out if your rubyforge_project has a different name
119
+ replace_header(head, :rubyforge_project)
120
+
121
+ # determine file list from git ls-files
122
+ files = `git ls-files`.
123
+ split("\n").
124
+ sort.
125
+ reject { |file| file =~ /^\./ }.
126
+ reject { |file| file =~ /^(rdoc|pkg|src|racklib)/ }.
127
+ map { |file| " #{file}" }.
128
+ join("\n")
129
+
130
+ # piece file back together and write
131
+ manifest = " s.files = %w[\n#{files}\n ]\n"
132
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
133
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
134
+ puts "Updated #{gemspec_file}"
135
+ end
136
+
137
+ task :validate do
138
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
139
+ unless libfiles.empty?
140
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
141
+ exit!
142
+ end
143
+ unless Dir['VERSION*'].empty?
144
+ puts "A `VERSION` file at root level violates Gem best practices."
145
+ exit!
146
+ end
147
+ end
@@ -0,0 +1,19 @@
1
+ module Trinidad
2
+ module Extensions
3
+ module Logging
4
+ VERSION = '0.1.0'
5
+ end
6
+
7
+ __DIR__ = File.dirname(__FILE__)
8
+ require File.expand_path('../trinidad-libs/juli-adapters', __DIR__)
9
+ require File.expand_path('../trinidad-libs/log4j-1.2.16', __DIR__)
10
+
11
+ class LoggingWebAppExtension < WebAppExtension
12
+ def configure(tomcat, app_context)
13
+ @options[:config] ||= 'config/trinidad-logging.properties'
14
+ java.lang.System.set_property('log4j.configuration',
15
+ java.io.File.new(File.expand_path(@options[:config])).to_url.to_s)
16
+ end
17
+ end
18
+ end
19
+ end
Binary file
Binary file
@@ -0,0 +1,69 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'trinidad_logging_extension'
16
+ s.version = '0.1.0'
17
+ s.date = '2010-07-14'
18
+ s.rubyforge_project = 'trinidad_logging_extension'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Logging extension for Trinidad"
23
+ s.description = "Configure logging service for Trinidad"
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["David Calavera"]
29
+ s.email = 'calavera@apache.org'
30
+ s.homepage = 'http://github.com/calavera/trinidad_logging_extension'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## Specify any RDoc options here. You'll want to add your README and
37
+ ## LICENSE files to the extra_rdoc_files list.
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.extra_rdoc_files = %w[README LICENSE]
40
+
41
+ ## List your runtime dependencies here. Runtime dependencies are those
42
+ ## that are needed for an end user to actually USE your code.
43
+ s.add_dependency('trinidad', '>=0.9.1')
44
+
45
+ ## List your development dependencies here. Development dependencies are
46
+ ## those that are only needed during development
47
+ s.add_development_dependency('rspec')
48
+ s.add_development_dependency('mocha')
49
+
50
+ ## Leave this section as-is. It will be automatically generated from the
51
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
52
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
53
+ # = MANIFEST =
54
+ s.files = %w[
55
+ History.txt
56
+ LICENSE
57
+ README
58
+ Rakefile
59
+ lib/trinidad_logging_extension.rb
60
+ trinidad-libs/juli-adapters.jar
61
+ trinidad-libs/log4j-1.2.16.jar
62
+ trinidad_logging_extension.gemspec
63
+ ]
64
+ # = MANIFEST =
65
+
66
+ ## Test files will be grabbed from the file list. Make sure the path glob
67
+ ## matches what you actually use.
68
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
69
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trinidad_logging_extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Calavera
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-07-14 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: trinidad
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: Configure logging service for Trinidad
46
+ email: calavera@apache.org
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README
53
+ - LICENSE
54
+ files:
55
+ - History.txt
56
+ - LICENSE
57
+ - README
58
+ - Rakefile
59
+ - lib/trinidad_logging_extension.rb
60
+ - trinidad-libs/juli-adapters.jar
61
+ - trinidad-libs/log4j-1.2.16.jar
62
+ - trinidad_logging_extension.gemspec
63
+ has_rdoc: true
64
+ homepage: http://github.com/calavera/trinidad_logging_extension
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options:
69
+ - --charset=UTF-8
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ requirements: []
85
+
86
+ rubyforge_project: trinidad_logging_extension
87
+ rubygems_version: 1.3.5
88
+ signing_key:
89
+ specification_version: 2
90
+ summary: Logging extension for Trinidad
91
+ test_files: []
92
+