logging-rails 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ tmp/
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.4.0 / 2012-04-04
2
+
3
+ Enhancements
4
+ - Compatibility with Ruby 1.8.7 [issue #2]
5
+ - Showing logging configuration is now optional
6
+
7
+ Bug Fixes
8
+ - Update "logging" depedency to any 1.X gem release
9
+
1
10
  == 0.3.0 / 2011-09-19
2
11
 
3
12
  Enhancements
data/README.md CHANGED
@@ -63,8 +63,9 @@ Logging.logger['UserController'].level = :debug
63
63
  ```
64
64
 
65
65
  When using the logging railtie, a small display of the current logging
66
- configuration will be displayed when the Rails logger is in the debug mode.
67
- A description of the display can be found [here](https://github.com/TwP/logging/blob/master/lib/logging.rb#L400).
66
+ configuration will be displayed when Rails is in development mode
67
+ (environment). A description of the display can be found
68
+ [here](https://github.com/TwP/logging/blob/master/lib/logging.rb#L400).
68
69
 
69
70
  ```
70
71
  root ............................................ *debug -T
@@ -79,11 +80,11 @@ root ............................................ *debug -T
79
80
  ```
80
81
 
81
82
  This is useful for understanding more complex logging configurations. It can
82
- be annoying in day-to-day usage. The soluation is to set the Rails logger to
83
- ```:info``` or higher.
83
+ be annoying in day-to-day usage. To disable, set the ```show_log_configuration```
84
+ setting to false in the environment specific configuration file.
84
85
 
85
86
  ```ruby
86
- Logging.logger['Rails'].level = :info
87
+ config.show_log_configuration = false
87
88
  ```
88
89
 
89
90
  Author
@@ -100,7 +101,7 @@ License
100
101
 
101
102
  The MIT License
102
103
 
103
- Copyright © 2011 by Tim Pease
104
+ Copyright © 2011-2012 by Tim Pease
104
105
 
105
106
  Permission is hereby granted, free of charge, to any person obtaining
106
107
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -15,6 +15,6 @@ Bones {
15
15
 
16
16
  use_gmail
17
17
 
18
- depend_on 'logging', '~> 1.6.1'
18
+ depend_on 'logging', '~> 1.6'
19
19
  }
20
20
 
@@ -14,6 +14,12 @@ module Logging::Rails
14
14
  insert_into_file 'config/environments/development.rb', comment % 'config.log_to = %w[stdout file]', :before => %r/^end\s*$/
15
15
  insert_into_file 'config/environments/production.rb', comment % 'config.log_to = %w[file]', :before => %r/^end\s*$/
16
16
  end
17
+
18
+ def insert_show_log_configuration
19
+ comment = "\n # Show the logging configuration on STDOUT\n config.show_log_configuration = %s\n"
20
+ insert_into_file 'config/environments/development.rb', comment % 'true', :before => %r/^end\s*$/
21
+ insert_into_file 'config/environments/production.rb', comment % 'false', :before => %r/^end\s*$/
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -97,9 +97,9 @@ Logging::Rails.configure do |config|
97
97
  #
98
98
  # The rolling file appender uses shared file locks to ensure that only one
99
99
  # process will roll the log file. Each process writing to the file must have
100
- # its own open file descriptor for flock to function properly. Reopening the
101
- # file descriptors afte forking ensure that each worker has a unique file
102
- # descriptor.
100
+ # its own open file descriptor for `flock` to function properly. Reopening
101
+ # the file descriptors after forking ensures that each worker has a unique
102
+ # file descriptor.
103
103
  #
104
104
  if defined?(PhusionPassenger)
105
105
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
@@ -12,11 +12,13 @@ module Logging::Rails
12
12
  #
13
13
  module Mixin
14
14
 
15
+ LOGGER_METHOD = RUBY_VERSION < '1.9' ? 'logger' : :logger
16
+
15
17
  # This method is called when the module is included into a class. It will
16
18
  # extend the including class so it also has a class-level `logger` method.
17
19
  #
18
20
  def self.included( other )
19
- other.__send__(:remove_method, :logger) if other.instance_methods.include? :logger
21
+ other.__send__(:remove_method, LOGGER_METHOD.to_sym) if other.instance_methods.include? LOGGER_METHOD
20
22
  other.extend self
21
23
  end
22
24
 
@@ -26,7 +28,7 @@ module Logging::Rails
26
28
  #
27
29
  def self.extended( other )
28
30
  eigenclass = class << other; self; end
29
- eigenclass.__send__(:remove_method, :logger) if eigenclass.instance_methods.include? :logger
31
+ eigenclass.__send__(:remove_method, LOGGER_METHOD.to_sym) if eigenclass.instance_methods.include? LOGGER_METHOD
30
32
  end
31
33
 
32
34
  # Returns the logger instance.
@@ -12,6 +12,7 @@ module Logging::Rails
12
12
 
13
13
  config.before_configuration do
14
14
  config.log_to = %w[file]
15
+ config.show_log_configuration = false
15
16
  end
16
17
 
17
18
  initializer 'logging.configure', :before => 'initialize_logger' do |app|
@@ -44,8 +45,10 @@ module Logging::Rails
44
45
  ::Rails.cache.logger = ::Logging::Logger[::Rails.cache]
45
46
  end
46
47
 
47
- config.after_initialize do
48
- ::Logging.show_configuration if ::Logging::Logger[::Rails].debug?
48
+ config.after_initialize do |app|
49
+ if app.config.show_log_configuration and (STDIN.tty? or defined?(Rails::Console))
50
+ ::Logging.show_configuration(STDERR)
51
+ end
49
52
  end
50
53
 
51
54
  end # Railtie
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-19 00:00:00.000000000Z
12
+ date: 2012-04-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logging
16
- requirement: &2154977120 !ruby/object:Gem::Requirement
16
+ requirement: &2165063980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.6.1
21
+ version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154977120
24
+ version_requirements: *2165063980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bones
27
- requirement: &2154976480 !ruby/object:Gem::Requirement
27
+ requirement: &2165062780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.7.1
32
+ version: 3.7.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2154976480
35
+ version_requirements: *2165062780
36
36
  description: ! 'A Railtie for for integrating the [Logging](https://github.com/TwP/logging)
37
37
 
38
38
  framework into your Rails 3 application.'
@@ -44,6 +44,7 @@ extra_rdoc_files:
44
44
  - lib/logging/rails/generators/USAGE
45
45
  - lib/logging/rails/generators/templates/logging.rb.erb
46
46
  files:
47
+ - .gitignore
47
48
  - History.txt
48
49
  - README.md
49
50
  - Rakefile
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  version: '0'
78
79
  requirements: []
79
80
  rubyforge_project: logging-rails
80
- rubygems_version: 1.8.6
81
+ rubygems_version: 1.8.11
81
82
  signing_key:
82
83
  specification_version: 3
83
84
  summary: A Railtie for for integrating the [Logging](https://github.