rails_semantic_logger 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a7c538cec8c358c81939c54ff8db6ce47e1ca46
|
4
|
+
data.tar.gz: 9eeb2407f8157458f9dcbf2db5577a06140df5a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2b620e2153ed6201c4c84434fe8e94d41fa1635dd414cd23b669b4258b5a4fc2cefddce129ab415976587ef9abdd53e6594d97c8e07f98be8fd2659d71fc4a2
|
7
|
+
data.tar.gz: 3aaeb1cd8136eeb906051a41ad45ce2d709bb46cf3c458f4fb520c9548f3de82898bf67eae8a32992b12b13de650b0d97ecbb9872311ee150640a66a6c5fc32d
|
@@ -56,18 +56,44 @@ module RailsSemanticLogger
|
|
56
56
|
# Silence asset logging
|
57
57
|
config.rails_semantic_logger.quiet_assets = false
|
58
58
|
|
59
|
-
#
|
60
|
-
# Use in a similar fashion to the Rails config.log_tags, except that it is now a hash.
|
59
|
+
# Override the output format for the primary Rails log file.
|
61
60
|
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
61
|
+
# Valid options:
|
62
|
+
# * :default
|
63
|
+
# Plain text output with no color.
|
64
|
+
# * :color
|
65
|
+
# Plain text output with color.
|
66
|
+
# * :json
|
67
|
+
# JSON output format.
|
68
|
+
# * class
|
68
69
|
#
|
69
|
-
#
|
70
|
-
#
|
70
|
+
# * Proc
|
71
|
+
# A block that will be called to format the output.
|
72
|
+
# It is supplied with the `log` entry and should return the formatted data.
|
73
|
+
#
|
74
|
+
# Note:
|
75
|
+
# * `:default` is automatically changed to `:color` if `config.colorize_logging` is `true`.
|
76
|
+
#
|
77
|
+
# JSON Example, in `application.rb`:
|
78
|
+
#
|
79
|
+
# config.rails_semantic_logger.format = :json
|
80
|
+
#
|
81
|
+
# Custom Example, create `app/lib/my_formatter.rb`:
|
82
|
+
#
|
83
|
+
# # My Custom colorized formatter
|
84
|
+
# class MyFormatter < SemanticLogger::Formatters::Color
|
85
|
+
# # Return the complete log level name in uppercase
|
86
|
+
# def level
|
87
|
+
# "#{color}log.level.upcase#{color_map.clear}"
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# # In application.rb:
|
92
|
+
# config.rails_semantic_logger.format = MyFormatter.new
|
93
|
+
config.rails_semantic_logger.format = :default
|
94
|
+
|
95
|
+
# DEPRECATED
|
96
|
+
# Instead, supply a Hash to config.log_tags
|
71
97
|
config.rails_semantic_logger.named_tags = nil
|
72
98
|
|
73
99
|
# Initialize SemanticLogger. In a Rails environment it will automatically
|
@@ -93,7 +119,8 @@ module RailsSemanticLogger
|
|
93
119
|
# Add the log file to the list of appenders
|
94
120
|
# Use the colorized formatter if Rails colorized logs are enabled
|
95
121
|
ap_options = config.rails_semantic_logger.ap_options
|
96
|
-
formatter = config.
|
122
|
+
formatter = config.rails_semantic_logger.format
|
123
|
+
formatter = SemanticLogger::Formatters::Color.new(ap: ap_options) if (formatter == :default) && (config.colorize_logging != false)
|
97
124
|
|
98
125
|
# Set internal logger to log to file only, in case another appender experiences errors during writes
|
99
126
|
appender = SemanticLogger::Appender::File.new(file_name: path, level: config.log_level, formatter: formatter)
|
@@ -209,8 +236,9 @@ module RailsSemanticLogger
|
|
209
236
|
require('rails_semantic_logger/extensions/action_controller/log_subscriber_processing') if defined?(ActionView::LogSubscriber)
|
210
237
|
end
|
211
238
|
|
212
|
-
|
213
|
-
|
239
|
+
# Backward compatibility
|
240
|
+
if config.rails_semantic_logger.named_tags
|
241
|
+
config.log_tags = config.rails_semantic_logger.named_tags
|
214
242
|
end
|
215
243
|
end
|
216
244
|
|
@@ -11,26 +11,25 @@ module ActiveRecord
|
|
11
11
|
return if IGNORE_PAYLOAD_NAMES.include?(name)
|
12
12
|
|
13
13
|
log_payload = {
|
14
|
-
sql:
|
14
|
+
sql: payload[:sql],
|
15
15
|
}
|
16
|
-
log
|
16
|
+
log = {
|
17
17
|
message: name,
|
18
18
|
payload: log_payload,
|
19
19
|
duration: event.duration
|
20
20
|
}
|
21
21
|
unless (payload[:binds] || []).empty?
|
22
22
|
log_payload[:binds] = binds = {}
|
23
|
-
|
24
|
-
if Rails.version.to_f >= 5.1
|
25
|
-
casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
|
26
|
-
payload[:binds].zip(casted_params).map { |attr, value|
|
27
|
-
render_bind(attr, value)
|
28
|
-
}
|
29
|
-
elsif Rails.version.to_i >= 5
|
23
|
+
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 && Rails::VERSION::TINY <= 2
|
30
24
|
payload[:binds].each do |attr|
|
31
25
|
attr_name, value = render_bind(attr)
|
32
26
|
binds[attr_name] = value
|
33
27
|
end
|
28
|
+
elsif Rails::VERSION::MAJOR >= 5
|
29
|
+
casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
|
30
|
+
payload[:binds].zip(casted_params).map { |attr, value|
|
31
|
+
render_bind(attr, value)
|
32
|
+
}
|
34
33
|
else
|
35
34
|
payload[:binds].each do |col, v|
|
36
35
|
attr_name, value = render_bind(col, v)
|
@@ -4,8 +4,6 @@ Rails::Rack::Logger
|
|
4
4
|
module Rails
|
5
5
|
module Rack
|
6
6
|
class Logger
|
7
|
-
mattr_accessor :named_tags
|
8
|
-
|
9
7
|
@logger = SemanticLogger['Rack']
|
10
8
|
|
11
9
|
def self.logger
|
@@ -15,9 +13,13 @@ module Rails
|
|
15
13
|
def call(env)
|
16
14
|
request = ActionDispatch::Request.new(env)
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
# Check for named tags (Hash)
|
17
|
+
if @taggers && !@taggers.empty?
|
18
|
+
tags = @taggers.is_a?(Hash) ? compute_named_tags(request) : compute_tags(request)
|
19
|
+
logger.tagged(tags) { call_app(request, env) }
|
20
|
+
else
|
21
|
+
call_app(request, env)
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
def started_request_message(request)
|
@@ -37,10 +39,11 @@ module Rails
|
|
37
39
|
self.class.logger
|
38
40
|
end
|
39
41
|
|
42
|
+
# Leave out any named tags with a nil value
|
40
43
|
def compute_named_tags(request) # :doc:
|
41
44
|
tagged = {}
|
42
|
-
|
43
|
-
resolved
|
45
|
+
@taggers.each_pair do |tag, value|
|
46
|
+
resolved =
|
44
47
|
case value
|
45
48
|
when Proc
|
46
49
|
value.call(request)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|