act-fluent-logger-rails 0.1.7 → 0.1.8

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: da022b5df3afeaed17575f337eeed42f918e6844
4
- data.tar.gz: 9332b7fbbefb9c774776d877b8de22ecb81aab92
3
+ metadata.gz: fb3b269dca0af21e27b94fe5fc0470ea8368f6d7
4
+ data.tar.gz: 1d8d7858797a83437b6af1ba5d6c434c31e41c82
5
5
  SHA512:
6
- metadata.gz: 7d1a7c89d8eedfb64b07ebd69e9b90972e29a2e47cde4b4a354e87cc2773b6972162635d6fbdfbeb21c91b87ba3ac2bbae661447d00378b0a917bef46653a133
7
- data.tar.gz: 71b560970dba82294045362445b55b6e13222e9bca1c037e7eab7e47b59c20b46f40a83def2aa91f667d262f158627866573067c6fe2587d58de5bec8f651482
6
+ metadata.gz: 9ba8d6eb2601eadb7aa8e1f0a91fcd8c9f0fd79c69832d11e66eb72a9b0284d917b6069c132978a4269b29329a0742c01cb99a331f0b6794af7aceb324acb4e7
7
+ data.tar.gz: a4b00ac33e2140b85f798fdd5e063124b7e31debb1a17213ba51ba68900c38a4d3ef6e5bdabf9605f3c74b415ca0dd0d939b3eb65ccdfa0fb96f4d3e353f7c08
@@ -1,3 +1,7 @@
1
+ ## 0.1.8 / Nov 14 2015
2
+
3
+ * Output Object#inspect if message is not String and not Exception.
4
+
1
5
  ## 0.1.7 / July 30 2015
2
6
 
3
7
  * Be able to log exceptions #15.
data/README.md CHANGED
@@ -61,7 +61,7 @@ or set an environment variable FLUENTD_URL
61
61
  * fluent_host: The host name of Fluentd.
62
62
  * fluent_port: The port number of Fluentd.
63
63
  * tag: The tag of the Fluentd event.
64
- * messages_type: The type of log messags. 'string' or 'array'.
64
+ * messages_type: The type of log messages. 'string' or 'array'.
65
65
  If it is 'string', the log messages is a String.
66
66
  ```
67
67
  2013-01-18T15:04:50+09:00 foo {"messages":"Started GET \"/\" for 127.0.0.1 at 2013-01-18 15:04:49 +0900\nProcessing by TopController#index as HTML\nCompleted 200 OK in 635ms (Views: 479.3ms | ActiveRecord: 39.6ms)"],"level":"INFO"}
@@ -75,10 +75,16 @@ module ActFluentLoggerRails
75
75
  def add_message(severity, message)
76
76
  @severity = severity if @severity < severity
77
77
 
78
- if message.is_a? Exception
79
- error_message = message.message + "\n" + message.backtrace.join("\n") + "\n"
80
- message = error_message
81
- end
78
+ message =
79
+ case message
80
+ when ::String
81
+ message
82
+ when ::Exception
83
+ "#{ message.message } (#{ message.class })\n" <<
84
+ (message.backtrace || []).join("\n")
85
+ else
86
+ message.inspect
87
+ end
82
88
 
83
89
  if message.encoding == Encoding::UTF_8
84
90
  @messages << message
@@ -1,3 +1,3 @@
1
1
  module ActFluentLoggerRails
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -73,8 +73,15 @@ EOF
73
73
  end
74
74
 
75
75
  describe 'frozen ascii-8bit string' do
76
- it 'join messages' do
76
+ before do
77
77
  logger.instance_variable_set(:@messages_type, :string)
78
+ end
79
+
80
+ after do
81
+ logger.instance_variable_set(:@messages_type, :array)
82
+ end
83
+
84
+ it 'join messages' do
78
85
  ascii = "\xe8\x8a\xb1".force_encoding('ascii-8bit').freeze
79
86
  logger.tagged([request]) {
80
87
  logger.info(ascii)
@@ -85,6 +92,29 @@ EOF
85
92
  end
86
93
  end
87
94
 
95
+ describe 'Exception' do
96
+ it 'output message, class, backtrace' do
97
+ begin
98
+ 3 / 0
99
+ rescue => e
100
+ logger.tagged([request]) {
101
+ logger.error(e)
102
+ }
103
+ expect(@my_logger.log[0][1][:messages][0]).
104
+ to match(%r|divided by 0 \(ZeroDivisionError\).*spec/logger_spec\.rb:|m)
105
+ end
106
+ end
107
+ end
108
+
109
+ describe 'Object' do
110
+ it 'output inspect' do
111
+ x = Object.new
112
+ logger.tagged([request]) {
113
+ logger.info(x)
114
+ }
115
+ expect(@my_logger.log[0][1][:messages][0]).to eq(x.inspect)
116
+ end
117
+ end
88
118
  end
89
119
 
90
120
  describe "use ENV['FLUENTD_URL']" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: act-fluent-logger-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAHARA Yoshinori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec