superlogger 0.0.1 → 0.0.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: a8233a0f1140b23ad1a79d954256e9f406e7dbf4
4
- data.tar.gz: 7fc49063ae14c89e033a224dc619e878401d8f33
3
+ metadata.gz: 6d6fc0c35cbd0c13cb78cab56470fd4e052dbfb0
4
+ data.tar.gz: 018b9488e84e2c6fb89ce167bfd164ddd27fa2a2
5
5
  SHA512:
6
- metadata.gz: 5bf2ca0272093a2b54928be31590756f57ddb0fb959c0fc4fc37cdd074cdaf51adbc903bfd5d549705708b53269e312afeb20ac04af50dec472ff41e7c4082c8
7
- data.tar.gz: 1b181052bfb35cc721824dde111d9d87b4aadc0b8605d944b7c1657e0afff478a1b2052c6033b8df04f64f262de53b84744c709c177bed20985f9799ae8cafef
6
+ metadata.gz: 7e9e122a303d23436eb3e098166e1400569dbeb4c91383b65181e5763a9cbe69440303a2a55b4030fc7e4db7329494b3de1c681612e982d164cbcb538dee4098
7
+ data.tar.gz: 1b73567f9b724ee95d4488a44a431e7801f96f4902d276d8e296840b8535da131eb115bceb2a8a0872a40d051490a582e7dd2bbef416088129e19d87699be654
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- Superlogger - Machine-readable logging for Rails [![Build Status](https://travis-ci.org/moexmen/superlogger.svg?branch=master)](https://travis-ci.org/moexmen/superlogger)
1
+ [![Build Status](https://travis-ci.org/moexmen/superlogger.svg?branch=master)](https://travis-ci.org/moexmen/superlogger)
2
+ [![Gem Version](https://badge.fury.io/rb/superlogger.svg)](https://badge.fury.io/rb/superlogger)
3
+ [![Dependency Status](https://gemnasium.com/badges/github.com/moexmen/superlogger.svg)](https://gemnasium.com/github.com/moexmen/superlogger)
4
+
5
+ Superlogger - Machine-readable logging for Rails
2
6
  =======
3
7
 
4
8
  Rails' default request logging is easy to read for humans but difficult for log aggregators such as Kibana, Graylog and Splunk. Superlogger transforms the logs into key-value pairs for easy parsing and adds useful details like Timestamp and Session ID for tracing purposes.
@@ -73,6 +73,7 @@ class Logger
73
73
  timestamp = time.strftime('%Y-%m-%d %H:%M:%S.%L')
74
74
  session_id = Superlogger::Logger.session_id[0..11]
75
75
  severity = severity.to_s.upcase[0]
76
+ msg.to_s.gsub!("\n", '\\n') # escape newlines
76
77
 
77
78
  "#{timestamp} | #{session_id} | #{severity} | #{msg}\n"
78
79
  end
@@ -1,3 +1,3 @@
1
1
  module Superlogger
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -292,3 +292,35 @@ Started GET "/assets/application.self-8f06a73c35179188914ab50e057157639fce1401c1
292
292
  2016-04-11 20:56:49.746 | b48534ea049a | D | action_view_log_subscriber:6 | view=_partial.html.erb | duration=0.4
293
293
  2016-04-11 20:56:49.746 | b48534ea049a | D | action_view_log_subscriber:6 | view=index.html.erb | duration=7.0
294
294
  2016-04-11 20:56:49.985 | b48534ea049a | I | action_controller_log_subscriber:29 | status=200 | total_duration=265.7 | view_duration=253.9 | db_duration=1.36
295
+ 2016-04-19 15:16:33.390 | b48534ea049a | I | middleware:28 | method=GET | path=/ | ip=::1
296
+ 2016-04-19 15:16:33.403 | b48534ea049a | D | action_controller_log_subscriber:9 | controller=Rails::WelcomeController | action=index | params={}
297
+ 2016-04-19 15:16:33.416 | b48534ea049a | D | action_view_log_subscriber:6 | view=index.html.erb | duration=1.7
298
+ 2016-04-19 15:16:33.417 | b48534ea049a | I | action_controller_log_subscriber:29 | status=200 | total_duration=13.18 | view_duration=12.86 | db_duration=0.0
299
+ 2016-04-19 15:16:38.081 | b48534ea049a | I | middleware:28 | method=GET | path=/a | ip=::1
300
+ 2016-04-19 15:16:38.082 | b48534ea049a | W | action_dispatch_debug_exceptions:6 | routing_error="/a"
301
+ 2016-04-19 15:16:38.129 | b48534ea049a | D | action_view_log_subscriber:6 | view=_trace.html.erb | duration=1.6
302
+ 2016-04-19 15:16:38.147 | b48534ea049a | D | action_view_log_subscriber:6 | view=_route.html.erb | duration=0.7
303
+ 2016-04-19 15:16:38.167 | b48534ea049a | D | action_view_log_subscriber:6 | view=_table.html.erb | duration=5.9
304
+ 2016-04-19 15:16:38.182 | b48534ea049a | D | action_view_log_subscriber:6 | view=_request_and_response.html.erb | duration=1.1
305
+ 2016-04-19 15:16:38.183 | b48534ea049a | D | action_view_log_subscriber:6 | view=routing_error.html.erb | duration=70.2
306
+ 2016-04-19 15:43:39.993 | b48534ea049a | I | middleware:28 | method=GET | path=/home/index | ip=::1
307
+ 2016-04-19 15:43:40.002 | b48534ea049a | D | action_controller_log_subscriber:9 | controller=HomeController | action=index | params={}
308
+ 2016-04-19 15:43:40.003 | b48534ea049a | F | action_controller_log_subscriber:19 | status=500 | exception=["ZeroDivisionError", "divided by 0"]
309
+ 2016-04-19 15:43:40.004 | b48534ea049a | F |
310
+ ZeroDivisionError (divided by 0):
311
+ app/controllers/home_controller.rb:3:in `/'
312
+ app/controllers/home_controller.rb:3:in `index'
313
+
314
+
315
+ 2016-04-19 15:43:40.115 | b48534ea049a | D | action_view_log_subscriber:6 | view=_source.erb | duration=4.3
316
+ 2016-04-19 15:43:40.130 | b48534ea049a | D | action_view_log_subscriber:6 | view=_trace.html.erb | duration=2.4
317
+ 2016-04-19 15:43:40.145 | b48534ea049a | D | action_view_log_subscriber:6 | view=_request_and_response.html.erb | duration=0.9
318
+ 2016-04-19 15:43:40.146 | b48534ea049a | D | action_view_log_subscriber:6 | view=diagnostics.html.erb | duration=54.7
319
+ 2016-04-19 15:48:20.385 | b48534ea049a | I | middleware:28 | method=GET | path=/home/index | ip=::1
320
+ 2016-04-19 15:48:20.400 | b48534ea049a | D | action_controller_log_subscriber:9 | controller=HomeController | action=index | params={}
321
+ 2016-04-19 15:48:20.401 | b48534ea049a | F | action_controller_log_subscriber:19 | status=500 | exception=["ZeroDivisionError", "divided by 0"]
322
+ 2016-04-19 15:48:20.403 | b48534ea049a | F | \nZeroDivisionError (divided by 0):\n app/controllers/home_controller.rb:3:in `/'\n app/controllers/home_controller.rb:3:in `index'\n\n
323
+ 2016-04-19 15:48:20.520 | b48534ea049a | D | action_view_log_subscriber:6 | view=_source.erb | duration=5.4
324
+ 2016-04-19 15:48:20.537 | b48534ea049a | D | action_view_log_subscriber:6 | view=_trace.html.erb | duration=3.4
325
+ 2016-04-19 15:48:20.553 | b48534ea049a | D | action_view_log_subscriber:6 | view=_request_and_response.html.erb | duration=1.2
326
+ 2016-04-19 15:48:20.553 | b48534ea049a | D | action_view_log_subscriber:6 | view=diagnostics.html.erb | duration=54.2
@@ -1670,3 +1670,63 @@
1670
1670
  2016-04-11 21:34:11.421 | NS-703551298 | I | ----------------------------------------
1671
1671
  2016-04-11 21:34:11.421 | NS-703551298 | I | SuperloggerTest: test_without_session_id
1672
1672
  2016-04-11 21:34:11.421 | NS-703551298 | I | ----------------------------------------
1673
+ 2016-04-19 15:15:04.958 | NS-701516138 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.07
1674
+ 2016-04-19 15:15:04.959 | NS-701516138 | I | ----------------------------------------
1675
+ 2016-04-19 15:15:04.959 | NS-701516138 | I | SuperloggerTest: test_without_session_id
1676
+ 2016-04-19 15:15:04.959 | NS-701516138 | I | ----------------------------------------
1677
+ 2016-04-19 15:15:49.223 | NS-703455374 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1678
+ 2016-04-19 15:15:49.223 | NS-703455374 | I | -----------------------------
1679
+ 2016-04-19 15:15:49.223 | NS-703455374 | I | SuperloggerTest: test_version
1680
+ 2016-04-19 15:15:49.223 | NS-703455374 | I | -----------------------------
1681
+ 2016-04-19 15:41:57.882 | NS-703094999 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1682
+ 2016-04-19 15:41:57.883 | NS-703094999 | I | ------------------------------------
1683
+ 2016-04-19 15:41:57.883 | NS-703094999 | I | SuperloggerTest: test_multiple_lines
1684
+ 2016-04-19 15:41:57.883 | NS-703094999 | I | ------------------------------------
1685
+ 2016-04-19 15:42:12.230 | NS-702758197 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1686
+ 2016-04-19 15:42:12.230 | NS-702758197 | I | ------------------------------------
1687
+ 2016-04-19 15:42:12.230 | NS-702758197 | I | SuperloggerTest: test_multiple_lines
1688
+ 2016-04-19 15:42:12.230 | NS-702758197 | I | ------------------------------------
1689
+ 2016-04-19 15:42:42.108 | NS-703465650 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1690
+ 2016-04-19 15:42:42.108 | NS-703465650 | I | ------------------------------------
1691
+ 2016-04-19 15:42:42.108 | NS-703465650 | I | SuperloggerTest: test_multiple_lines
1692
+ 2016-04-19 15:42:42.108 | NS-703465650 | I | ------------------------------------
1693
+ 2016-04-19 15:43:56.751 | NS-702391825 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.09
1694
+ 2016-04-19 15:43:56.752 | NS-702391825 | I | ------------------------------------
1695
+ 2016-04-19 15:43:56.752 | NS-702391825 | I | SuperloggerTest: test_multiple_lines
1696
+ 2016-04-19 15:43:56.752 | NS-702391825 | I | ------------------------------------
1697
+ 2016-04-19 15:47:47.972 | NS-703662867 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1698
+ 2016-04-19 15:47:47.972 | NS-703662867 | I | ------------------------------------
1699
+ 2016-04-19 15:47:47.972 | NS-703662867 | I | SuperloggerTest: test_multiple_lines
1700
+ 2016-04-19 15:47:47.972 | NS-703662867 | I | ------------------------------------
1701
+ 2016-04-19 15:48:00.074 | NS-702720029 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.09
1702
+ 2016-04-19 15:48:00.074 | NS-702720029 | I | ------------------------------------
1703
+ 2016-04-19 15:48:00.074 | NS-702720029 | I | SuperloggerTest: test_multiple_lines
1704
+ 2016-04-19 15:48:00.074 | NS-702720029 | I | ------------------------------------
1705
+ 2016-04-19 15:54:21.219 | NS-703518373 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.1
1706
+ 2016-04-19 15:54:21.219 | NS-703518373 | I | ------------------------------------
1707
+ 2016-04-19 15:54:21.219 | NS-703518373 | I | SuperloggerTest: test_multiple_lines
1708
+ 2016-04-19 15:54:21.219 | NS-703518373 | I | ------------------------------------
1709
+ 2016-04-19 15:58:50.438 | NS-703128680 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1710
+ 2016-04-19 15:58:50.438 | NS-703128680 | I | -------------------------------------
1711
+ 2016-04-19 15:58:50.438 | NS-703128680 | I | SuperloggerTest: test_caller_location
1712
+ 2016-04-19 15:58:50.438 | NS-703128680 | I | -------------------------------------
1713
+ 2016-04-19 15:59:09.279 | NS-701319970 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.09
1714
+ 2016-04-19 15:59:09.279 | NS-701319970 | I | --------------------------------
1715
+ 2016-04-19 15:59:09.279 | NS-701319970 | I | SuperloggerTest: test_log_format
1716
+ 2016-04-19 15:59:09.279 | NS-701319970 | I | --------------------------------
1717
+ 2016-04-19 16:00:06.031 | NS-703609809 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1718
+ 2016-04-19 16:00:06.031 | NS-703609809 | I | --------------------------------
1719
+ 2016-04-19 16:00:06.031 | NS-703609809 | I | SuperloggerTest: test_log_levels
1720
+ 2016-04-19 16:00:06.031 | NS-703609809 | I | --------------------------------
1721
+ 2016-04-19 16:01:34.316 | NS-702910618 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1722
+ 2016-04-19 16:01:34.316 | NS-702910618 | I | --------------------------------
1723
+ 2016-04-19 16:01:34.316 | NS-702910618 | I | SuperloggerTest: test_log_format
1724
+ 2016-04-19 16:01:34.316 | NS-702910618 | I | --------------------------------
1725
+ 2016-04-19 16:01:50.723 | NS-703618659 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.08
1726
+ 2016-04-19 16:01:50.724 | NS-703618659 | I | --------------------------------
1727
+ 2016-04-19 16:01:50.724 | NS-703618659 | I | SuperloggerTest: test_middleware
1728
+ 2016-04-19 16:01:50.724 | NS-703618659 | I | --------------------------------
1729
+ 2016-04-19 16:26:28.693 | NS-701772242 | D | active_record_log_subscriber:24 | sql=begin transaction | params=[] | duration=0.12
1730
+ 2016-04-19 16:26:28.694 | NS-701772242 | I | -----------------------------
1731
+ 2016-04-19 16:26:28.694 | NS-701772242 | I | SuperloggerTest: test_version
1732
+ 2016-04-19 16:26:28.694 | NS-701772242 | I | -----------------------------
@@ -131,4 +131,10 @@ class SuperloggerTest < ActiveSupport::TestCase
131
131
  assert_match(/duration=\d.\d/, fields[6])
132
132
  assert_operator fields[6].split('=').last.to_f, :>, 0
133
133
  end
134
+
135
+ test 'escape new lines' do
136
+ Superlogger::Logger.debug var: 'first\nsecond'
137
+
138
+ assert_match 'first\\nsecond', output[0].last
139
+ end
134
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superlogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soh Yu Ming
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails