onelinejson 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -9
- data/lib/onelinejson/version.rb +1 -1
- data/lib/onelinejson.rb +7 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,25 +1,51 @@
|
|
1
1
|
# Onelinejson
|
2
2
|
|
3
|
-
|
3
|
+
Onelinejson gives you one line Rails logs. The only thing you need to do is specifying the gem in your Gemfile!
|
4
|
+
|
5
|
+
```json
|
6
|
+
{
|
7
|
+
"debug_info": {},
|
8
|
+
"response": {
|
9
|
+
"view": 0.8,
|
10
|
+
"duration": 79.43,
|
11
|
+
"status": 200
|
12
|
+
},
|
13
|
+
"request": {
|
14
|
+
"uuid": "47e4a7fa-7e8e-430b-b66a-1509f6e6da5a",
|
15
|
+
"path": "/tasks/1",
|
16
|
+
"action": "show",
|
17
|
+
"controller": "tasks",
|
18
|
+
"date": "2013-11-19T15:05:05Z",
|
19
|
+
"format": "*/*",
|
20
|
+
"headers": {
|
21
|
+
"HTTP_VERSION": "HTTP/1.1",
|
22
|
+
"HTTP_ACCEPT": "*/*",
|
23
|
+
"HTTP_HOST": "localhost:3000",
|
24
|
+
"HTTP_USER_AGENT": "curl/7.30.0"
|
25
|
+
},
|
26
|
+
"ip": "127.0.0.1",
|
27
|
+
"method": "GET",
|
28
|
+
"params": {
|
29
|
+
"id": "1"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
```
|
34
|
+
|
35
|
+
It has the following top level entries: `request`, `response` and `debug_info`. `request` contains `params`, `headers` and the usual stuff. `response` contains the status code and runtimes. `debug_info` is the place where you can put in stuff temporarily and use it for debugging.
|
4
36
|
|
5
37
|
## Installation
|
6
38
|
|
7
39
|
Add this line to your application's Gemfile:
|
8
40
|
|
41
|
+
gem "lograge", git: "git@github.com:i0rek/lograge.git", branch: "config_subscriber"
|
9
42
|
gem 'onelinejson'
|
10
43
|
|
44
|
+
You need my lograge repo for now, until my PR got merged which I hope will happen eventually.
|
11
45
|
And then execute:
|
12
46
|
|
13
47
|
$ bundle
|
14
48
|
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install onelinejson
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
49
|
## Contributing
|
24
50
|
|
25
51
|
1. Fork it
|
data/lib/onelinejson/version.rb
CHANGED
data/lib/onelinejson.rb
CHANGED
@@ -98,11 +98,17 @@ module Onelinejson
|
|
98
98
|
module AppControllerMethods
|
99
99
|
def append_info_to_payload(payload)
|
100
100
|
super
|
101
|
+
headers = if request.headers.respond_to?(:env)
|
102
|
+
request.headers.env
|
103
|
+
elsif request.headers.respond_to?(:to_hash)
|
104
|
+
request.headers.to_hash
|
105
|
+
end.reject {|k, v| !k.starts_with?("HTTP_") || k == "HTTP_AUTHORIZATION"}
|
106
|
+
|
101
107
|
payload[:request] = {
|
102
108
|
params: params.reject { |k,v|
|
103
109
|
k == 'controller' || k == 'action' || v.is_a?(ActionDispatch::Http::UploadedFile)
|
104
110
|
},
|
105
|
-
headers:
|
111
|
+
headers: headers,
|
106
112
|
ip: request.ip,
|
107
113
|
uuid: request.env['action_dispatch.request_id'],
|
108
114
|
controller: self.class.name,
|