logstasher 0.2.4 → 0.2.5
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.
- data/.travis.yml +8 -2
- data/Gemfile +1 -1
- data/README.md +47 -10
- data/lib/logstasher/version.rb +1 -1
- metadata +4 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,21 +1,58 @@
|
|
1
1
|
# Logstasher - Awesome Logging for Rails [](https://secure.travis-ci.org/shadabahmed/logstasher)
|
2
2
|
|
3
|
-
This gem is heavily inspired from [lograge](https://github.com/roidrage/lograge) but it's focused on one thing and one thing only
|
3
|
+
This gem is heavily inspired from [lograge](https://github.com/roidrage/lograge) but it's focused on one thing and one thing only. That's making your logs awesome like this:
|
4
4
|
|
5
|
-
|
5
|
+
[](http://i.imgur.com/zZXWQNp.png)
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
How it's done ?
|
8
|
+
|
9
|
+
By, using these awesome tools:
|
10
|
+
* [Logstash](http://logstash.net) - Store and index your logs
|
9
11
|
* [Kibana](http://kibana.org/) - for awesome visualization. This is optional though, and you can use any other visualizer
|
10
12
|
|
13
|
+
To know how to setup these tools - visit my [blog](http://shadabahmed.com/blog/2013/04/30/logstasher-for-awesome-rails-logging)
|
14
|
+
|
15
|
+
## About logstasher
|
16
|
+
|
17
|
+
This gem purely focuses on how to generate logstash compatible logs i.e. *logstash json event format*, without any overhead. Infact, logstasher logs to a separate log file named `logstash_<environment>.log`.
|
18
|
+
The reason for this separation:
|
19
|
+
* To have a pure json log file
|
20
|
+
* Prevent any logger messages(e.g. info) getting into our pure json logs
|
21
|
+
|
22
|
+
Before **logstasher** :
|
23
|
+
|
24
|
+
```
|
25
|
+
Started GET "/login" for 10.109.10.135 at 2013-04-30 08:59:01 -0400
|
26
|
+
Processing by SessionsController#new as HTML
|
27
|
+
Rendered sessions/new.html.haml within layouts/application (4.3ms)
|
28
|
+
Rendered shared/_javascript.html.haml (0.6ms)
|
29
|
+
Rendered shared/_flashes.html.haml (0.2ms)
|
30
|
+
Rendered shared/_header.html.haml (52.9ms)
|
31
|
+
Rendered shared/_title.html.haml (0.2ms)
|
32
|
+
Rendered shared/_footer.html.haml (0.2ms)
|
33
|
+
Completed 200 OK in 532ms (Views: 62.4ms | ActiveRecord: 0.0ms | ND API: 0.0ms)
|
34
|
+
```
|
35
|
+
|
36
|
+
After **logstasher**:
|
37
|
+
|
38
|
+
```
|
39
|
+
{"@source":"unknown","@tags":["request"],"@fields":{"method":"GET","path":"/","format":"html","controller":"file_servers"
|
40
|
+
,"action":"index","status":200,"duration":28.34,"view":25.96,"db":0.88,"ip":"127.0.0.1","route":"file_servers#index",
|
41
|
+
"parameters":"","ndapi_time":null,"uuid":"e81ecd178ed3b591099f4d489760dfb6","user":"shadab_ahmed@abc.com",
|
42
|
+
"site":"internal"},"@timestamp":"2013-04-30T13:00:46.354500+00:00"}
|
43
|
+
```
|
44
|
+
|
45
|
+
By default, the older format rails request logs are disabled, though you can enable them.
|
46
|
+
|
11
47
|
## Installation
|
12
48
|
|
13
49
|
In your Gemfile:
|
14
50
|
|
15
51
|
gem 'logstasher'
|
16
52
|
|
17
|
-
### Configure your
|
53
|
+
### Configure your `<environment>.rb` e.g. `development.rb`
|
18
54
|
|
55
|
+
# Enable the logstasher logs for the current environment
|
19
56
|
config.logstasher.enabled = true
|
20
57
|
|
21
58
|
# This line is optional if you do not want to supress app logs in your <environment>.log
|
@@ -23,22 +60,22 @@ In your Gemfile:
|
|
23
60
|
|
24
61
|
## Adding custom fields to the log
|
25
62
|
|
26
|
-
Since some fields are very specific to your application for e.g. *user_name*, it is left upto you to add them. Here's how to add those to the logs:
|
63
|
+
Since some fields are very specific to your application for e.g. *user_name*, so it is left upto you, to add them. Here's how to add those fields to the logs:
|
27
64
|
|
28
|
-
#
|
65
|
+
# Create a file - config/initializers/logstasher.rb
|
29
66
|
|
30
67
|
if LogStasher.enabled
|
31
68
|
LogStasher.add_custom_fields do |fields|
|
32
69
|
fields[:user] = current_user && current_user.mail
|
33
70
|
fields[:site] = request.path =~ /^\/api/ ? 'api' : 'user'
|
34
71
|
|
35
|
-
# If you are using custom instrumentation, just add
|
72
|
+
# If you are using custom instrumentation, just add it to logstasher custom fields
|
36
73
|
LogStasher.custom_fields << :myapi_runtime
|
37
74
|
end
|
38
75
|
end
|
39
76
|
|
40
77
|
## Versions
|
41
|
-
All versions require Rails 3.0.x and higher and Ruby 1.9.2
|
78
|
+
All versions require Rails 3.0.x and higher and Ruby 1.9.2+. Tested on Rails 4 and Ruby 2.0
|
42
79
|
|
43
80
|
## Development
|
44
81
|
- Run tests - `rake`
|
@@ -46,4 +83,4 @@ All versions require Rails 3.0.x and higher and Ruby 1.9.2+
|
|
46
83
|
|
47
84
|
## Copyright
|
48
85
|
|
49
|
-
Copyright (c) 2013 Shadab Ahmed, released under the MIT license
|
86
|
+
Copyright (c) 2013 Shadab Ahmed, released under the MIT license
|
data/lib/logstasher/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstasher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logstash-event
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
segments:
|
115
115
|
- 0
|
116
|
-
hash:
|
116
|
+
hash: 66757699131384912
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash:
|
125
|
+
hash: 66757699131384912
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project: logstasher
|
128
128
|
rubygems_version: 1.8.25
|