logging-rails 0.4.0 → 0.5.0
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/Rakefile +4 -3
- data/lib/logging/rails.rb +1 -12
- data/lib/logging/rails/generators/install_generator.rb +0 -2
- data/lib/logging/rails/generators/templates/logging.rb.erb +11 -10
- data/lib/logging/rails/mixin.rb +3 -10
- data/lib/logging/rails/railtie.rb +3 -7
- data/script/bootstrap +13 -0
- data/version.txt +1 -1
- metadata +57 -24
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1be38141e31f05fe6baed371d260c2a1c229ea3a
|
4
|
+
data.tar.gz: 3abf4ffefe2d1237583217ef7415f08cc7c8b17d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f94aba9e789930bb698a4c2edd9a74457103e34821b320e7e6d1ba9cbbb5de05de5e57ec7d9aa3d425ce63c5543c57865c52b11b15c0b2336c39015db4bfc78d
|
7
|
+
data.tar.gz: 7e43115bb985c4b06bec69f37f51f7884dd6ee3911ac173a70b4cafddcc5f7910021f63c253f147a9486b5cceaad5045af9b9a879938e5f853ce6113722329f6
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,9 +8,9 @@ Features
|
|
8
8
|
--------
|
9
9
|
|
10
10
|
The railtie provides only one feature - integration of the **Logging**
|
11
|
-
framework into your Rails
|
11
|
+
framework into your Rails application. But this gives you quite a bit of
|
12
12
|
flexibility to format your log messages and direct them to multiple logging
|
13
|
-
|
13
|
+
destinations: stdout with colors, a rolling log file, email, or even get a
|
14
14
|
growl notification.
|
15
15
|
|
16
16
|
Install
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
begin
|
3
2
|
require 'bones'
|
4
3
|
rescue LoadError
|
@@ -15,6 +14,8 @@ Bones {
|
|
15
14
|
|
16
15
|
use_gmail
|
17
16
|
|
18
|
-
depend_on 'logging', '
|
19
|
-
}
|
17
|
+
depend_on 'logging', '>= 1.8'
|
20
18
|
|
19
|
+
depend_on 'bones-git', '~> 1.3', :development => true
|
20
|
+
depend_on 'rails', '~> 4', :development => true
|
21
|
+
}
|
data/lib/logging/rails.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
1
|
require 'logging'
|
3
|
-
include Logging.globally
|
4
|
-
|
5
2
|
require 'rails' if !defined? Rails or Rails.version
|
6
3
|
|
7
4
|
if Rails.version < '3'
|
@@ -17,7 +14,6 @@ module Logging::Rails
|
|
17
14
|
|
18
15
|
class << self
|
19
16
|
# Returns the version string for the library.
|
20
|
-
#
|
21
17
|
def version
|
22
18
|
@version ||= File.read(path('version.txt')).strip
|
23
19
|
end
|
@@ -25,7 +21,6 @@ module Logging::Rails
|
|
25
21
|
# Stores the given Logging configuration block for later evalution by the
|
26
22
|
# Railtie. This method is used in the 'config/logging.rb' configuration
|
27
23
|
# file.
|
28
|
-
#
|
29
24
|
def configure( &block )
|
30
25
|
@configuration = block
|
31
26
|
end
|
@@ -34,7 +29,6 @@ module Logging::Rails
|
|
34
29
|
|
35
30
|
# Returns the path for Mr Bones. If any arguments are given,
|
36
31
|
# they will be joined to the end of the path using <tt>File.join</tt>.
|
37
|
-
#
|
38
32
|
def path( *args )
|
39
33
|
rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
40
34
|
if block_given?
|
@@ -50,7 +44,6 @@ module Logging::Rails
|
|
50
44
|
|
51
45
|
# Returns the lib path for Mr Bones. If any arguments are given,
|
52
46
|
# they will be joined to the end of the path using <tt>File.join</tt>.
|
53
|
-
#
|
54
47
|
def libpath( *args )
|
55
48
|
rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
56
49
|
if block_given?
|
@@ -69,14 +62,11 @@ module Logging::Rails
|
|
69
62
|
require 'logging/rails/railtie'
|
70
63
|
require 'logging/rails/mixin'
|
71
64
|
}
|
72
|
-
|
73
|
-
end # Logging::Rails
|
74
|
-
|
65
|
+
end
|
75
66
|
|
76
67
|
# Here we need to remove the Rails LogTailer from the list of middlewares. The
|
77
68
|
# Logging framework is fully capable of sending log events to multiple logging
|
78
69
|
# destinations.
|
79
|
-
#
|
80
70
|
module Rails
|
81
71
|
class Server < ::Rack::Server
|
82
72
|
def middleware_without_log_tailer
|
@@ -88,4 +78,3 @@ module Rails
|
|
88
78
|
alias :middleware :middleware_without_log_tailer
|
89
79
|
end
|
90
80
|
end
|
91
|
-
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
1
|
Logging::Rails.configure do |config|
|
3
2
|
|
4
|
-
#
|
3
|
+
# Configure the Logging framework with the default log levels
|
4
|
+
Logging.init %w[debug info warn error fatal]
|
5
|
+
|
6
|
+
# Objects will be converted to strings using the :inspect method.
|
5
7
|
Logging.format_as :inspect
|
6
8
|
|
7
9
|
# The default layout used by the appenders.
|
@@ -11,7 +13,6 @@ Logging::Rails.configure do |config|
|
|
11
13
|
# to the pattern layout. Color schemes should only be used with appenders
|
12
14
|
# that write to STDOUT or STDERR; inserting terminal color codes into a file
|
13
15
|
# is generally considered bad form.
|
14
|
-
#
|
15
16
|
Logging.color_scheme( 'bright',
|
16
17
|
:levels => {
|
17
18
|
:info => :green,
|
@@ -27,7 +28,6 @@ Logging::Rails.configure do |config|
|
|
27
28
|
# Configure an appender that will write log events to STDOUT. A colorized
|
28
29
|
# pattern layout is used to format the log events into strings before
|
29
30
|
# writing.
|
30
|
-
#
|
31
31
|
Logging.appenders.stdout( 'stdout',
|
32
32
|
:auto_flushing => true,
|
33
33
|
:layout => Logging.layouts.pattern(
|
@@ -40,7 +40,6 @@ Logging::Rails.configure do |config|
|
|
40
40
|
# be rolled on a daily basis, and the past 7 rolled files will be kept.
|
41
41
|
# Older files will be deleted. The default pattern layout is used when
|
42
42
|
# formatting log events into strings.
|
43
|
-
#
|
44
43
|
Logging.appenders.rolling_file( 'file',
|
45
44
|
:filename => config.paths<%= Rails.version < "3.1" ? ".log" : "['log']" %>.first,
|
46
45
|
:keep => 7,
|
@@ -50,11 +49,15 @@ Logging::Rails.configure do |config|
|
|
50
49
|
:layout => layout
|
51
50
|
) if config.log_to.include? 'file'
|
52
51
|
|
52
|
+
=begin
|
53
|
+
# NOTE: You will need to install the `logging-email` gem to use this appender
|
54
|
+
# with loggging-2.0. The email appender was extracted into a plugin gem. That
|
55
|
+
# is the reason this code is commented out.
|
56
|
+
#
|
53
57
|
# Configure an appender that will send an email for "error" and "fatal" log
|
54
58
|
# events. All other log events will be ignored. Furthermore, log events will
|
55
59
|
# be buffered for one minute (or 200 events) before an email is sent. This
|
56
60
|
# is done to prevent a flood of messages.
|
57
|
-
#
|
58
61
|
Logging.appenders.email( 'email',
|
59
62
|
:from => "server@#{config.action_mailer.smtp_settings[:domain]}",
|
60
63
|
:to => "developers@#{config.action_mailer.smtp_settings[:domain]}",
|
@@ -70,6 +73,7 @@ Logging::Rails.configure do |config|
|
|
70
73
|
:level => :error, # only process log events that are "error" or "fatal"
|
71
74
|
:layout => layout
|
72
75
|
) if config.log_to.include? 'email'
|
76
|
+
=end
|
73
77
|
|
74
78
|
# Setup the root logger with the Rails log level and the desired set of
|
75
79
|
# appenders. The list of appenders to use should be set in the environment
|
@@ -100,12 +104,9 @@ Logging::Rails.configure do |config|
|
|
100
104
|
# its own open file descriptor for `flock` to function properly. Reopening
|
101
105
|
# the file descriptors after forking ensures that each worker has a unique
|
102
106
|
# file descriptor.
|
103
|
-
|
104
|
-
if defined?(PhusionPassenger)
|
107
|
+
if defined? PhusionPassenger
|
105
108
|
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
106
109
|
Logging.reopen if forked
|
107
110
|
end
|
108
111
|
end
|
109
|
-
|
110
112
|
end
|
111
|
-
|
data/lib/logging/rails/mixin.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Logging::Rails
|
3
2
|
|
4
3
|
# Include this module into your ApplicationController to provide
|
@@ -7,16 +6,14 @@ module Logging::Rails
|
|
7
6
|
#
|
8
7
|
# Alternatively, you can use the `include Logging.globally` trick to add a
|
9
8
|
# `logger` method to every Object in the ruby interpreter. See
|
10
|
-
# https://github.com/TwP/logging/blob/master/lib/logging.rb#
|
9
|
+
# https://github.com/TwP/logging/blob/master/lib/logging.rb#L194 for more
|
11
10
|
# details.
|
12
|
-
#
|
13
11
|
module Mixin
|
14
12
|
|
15
13
|
LOGGER_METHOD = RUBY_VERSION < '1.9' ? 'logger' : :logger
|
16
14
|
|
17
15
|
# This method is called when the module is included into a class. It will
|
18
16
|
# extend the including class so it also has a class-level `logger` method.
|
19
|
-
#
|
20
17
|
def self.included( other )
|
21
18
|
other.__send__(:remove_method, LOGGER_METHOD.to_sym) if other.instance_methods.include? LOGGER_METHOD
|
22
19
|
other.extend self
|
@@ -25,18 +22,14 @@ module Logging::Rails
|
|
25
22
|
# This method is called when the modules is extended into another class or
|
26
23
|
# module. It will remove any existing `logger` method and insert its own
|
27
24
|
# version.
|
28
|
-
#
|
29
25
|
def self.extended( other )
|
30
26
|
eigenclass = class << other; self; end
|
31
27
|
eigenclass.__send__(:remove_method, LOGGER_METHOD.to_sym) if eigenclass.instance_methods.include? LOGGER_METHOD
|
32
28
|
end
|
33
29
|
|
34
30
|
# Returns the logger instance.
|
35
|
-
#
|
36
31
|
def logger
|
37
32
|
@logger ||= ::Logging::Logger[self]
|
38
33
|
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end # Logging::Rails
|
42
|
-
|
34
|
+
end
|
35
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
1
|
module Logging::Rails
|
3
2
|
|
4
3
|
# The Railtie is used to inject the Logging framework into the Rails
|
5
4
|
# application.
|
6
|
-
#
|
7
5
|
class Railtie < ::Rails::Railtie
|
8
6
|
|
9
7
|
generators do
|
@@ -18,7 +16,7 @@ module Logging::Rails
|
|
18
16
|
initializer 'logging.configure', :before => 'initialize_logger' do |app|
|
19
17
|
file = ::Rails.root.join('config/logging.rb')
|
20
18
|
load file if File.exists? file
|
21
|
-
::Logging::Rails.configuration.call
|
19
|
+
::Logging::Rails.configuration.call(app.config) if ::Logging::Rails.configuration
|
22
20
|
end
|
23
21
|
|
24
22
|
initializer 'logging.initialize', :before => 'initialize_logger' do
|
@@ -50,7 +48,5 @@ module Logging::Rails
|
|
50
48
|
::Logging.show_configuration(STDERR)
|
51
49
|
end
|
52
50
|
end
|
53
|
-
|
54
|
-
|
55
|
-
end # Logging::Rails
|
56
|
-
|
51
|
+
end
|
52
|
+
end
|
data/script/bootstrap
ADDED
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
metadata
CHANGED
@@ -1,41 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logging-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Pease
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: logging
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
19
|
+
version: '1.8'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bones-git
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
25
55
|
- !ruby/object:Gem::Dependency
|
26
56
|
name: bones
|
27
|
-
requirement:
|
28
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
29
58
|
requirements:
|
30
|
-
- -
|
59
|
+
- - ">="
|
31
60
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.
|
61
|
+
version: 3.8.3
|
33
62
|
type: :development
|
34
63
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
|
37
|
-
|
38
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.8.3
|
69
|
+
description: |-
|
70
|
+
A Railtie for for integrating the [Logging](https://github.com/TwP/logging)
|
71
|
+
framework into your Rails 3 application.
|
39
72
|
email: tim.pease@gmail.com
|
40
73
|
executables: []
|
41
74
|
extensions: []
|
@@ -44,7 +77,7 @@ extra_rdoc_files:
|
|
44
77
|
- lib/logging/rails/generators/USAGE
|
45
78
|
- lib/logging/rails/generators/templates/logging.rb.erb
|
46
79
|
files:
|
47
|
-
- .gitignore
|
80
|
+
- ".gitignore"
|
48
81
|
- History.txt
|
49
82
|
- README.md
|
50
83
|
- Rakefile
|
@@ -55,31 +88,31 @@ files:
|
|
55
88
|
- lib/logging/rails/generators/templates/logging.rb.erb
|
56
89
|
- lib/logging/rails/mixin.rb
|
57
90
|
- lib/logging/rails/railtie.rb
|
91
|
+
- script/bootstrap
|
58
92
|
- version.txt
|
59
93
|
homepage: http://rubygems.org/gems/logging-rails
|
60
94
|
licenses: []
|
95
|
+
metadata: {}
|
61
96
|
post_install_message:
|
62
97
|
rdoc_options:
|
63
|
-
- --main
|
98
|
+
- "--main"
|
64
99
|
- README.md
|
65
100
|
require_paths:
|
66
101
|
- lib
|
67
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
103
|
requirements:
|
70
|
-
- -
|
104
|
+
- - ">="
|
71
105
|
- !ruby/object:Gem::Version
|
72
106
|
version: '0'
|
73
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
108
|
requirements:
|
76
|
-
- -
|
109
|
+
- - ">="
|
77
110
|
- !ruby/object:Gem::Version
|
78
111
|
version: '0'
|
79
112
|
requirements: []
|
80
113
|
rubyforge_project: logging-rails
|
81
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.2.2
|
82
115
|
signing_key:
|
83
|
-
specification_version:
|
116
|
+
specification_version: 4
|
84
117
|
summary: A Railtie for for integrating the [Logging](https://github.
|
85
118
|
test_files: []
|