Skip to content

Commit 4d7b8c4

Browse files
committed
Merge pull request #1 from zohrehj/master
Move initialization code to Railtie
2 parents d37ba21 + 68cff17 commit 4d7b8c4

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,9 @@ We use tagging to indicate application with a 2 letter code and environment with
4040
a single letter (e.g., p = production, s = staging).
4141

4242
````ruby
43-
# Add log subscriber to generate concise request messages at warning level
44-
config.middleware.use "ConciseLogging::LogMiddleware"
45-
ConciseLogging::LogSubscriber.attach_to :action_controller
46-
47-
# Configure logger to log warn and above to Papertrail app vis syslog
43+
# Configure logger to log warn and above
4844
config.log_level = :warn
4945
config.log_tags = ["cv-#{Rails.env[0]}"]
50-
config.colorize_logging = true
5146
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(File.join(Rails.root, "log", "#{Rails.env}.log")))
5247
````
5348

concise_logging.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
1717
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1818
spec.require_paths = ["lib"]
1919

20+
spec.add_dependency "rails", ">= 3.0"
21+
2022
spec.add_development_dependency "bundler", "~> 1.7"
2123
spec.add_development_dependency "rake", "~> 10.0"
2224
end

lib/concise_logging.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
require "concise_logging/version"
22
require "concise_logging/log_middleware"
33
require "concise_logging/log_subscriber"
4+
require "concise_logging/railtie" if defined? Rails

lib/concise_logging/railtie.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module ConciseLogging
2+
class Railtie < Rails::Railtie
3+
initializer "railtie.configure_rails_initialization" do |app|
4+
app.middleware.use ConciseLogging::LogMiddleware
5+
end
6+
7+
ConciseLogging::LogSubscriber.attach_to :action_controller
8+
end
9+
end

0 commit comments

Comments
 (0)