redis_logstash 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTJjYTFlMGE5N2MzOTVjMjVlMzA3Mzk4ZTRkMWU4MmRhMTQyZmNjNg==
5
+ data.tar.gz: !binary |-
6
+ MmFiYTBlNzgzYmIyMTQyNGM5OTZhZGE2MTc4YzQ4N2RiN2ZiMjc5OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGU5N2FhNTUwNjQ4YmM0NmNkNDBhYTAxZWYxN2I2OTA4NjA3MjUzMWYyOWQ1
10
+ MThjNTZmOGExMzAyNzgyNDk2ZmU5NWUzMWFhNjBjZTMyMzE1YzRlZDg2Y2Yy
11
+ ZjVjYTExZGFhMDk5NzBjZjVhY2I2MzEyMzI1NmM3MjM0OWQ5YmM=
12
+ data.tar.gz: !binary |-
13
+ YTcyNDVlMmI3NGQxYTQxNmYwYzhjMDM3YzcxZDEzZDBhNTc0ZjI1NmVjZDZi
14
+ NGRkOTY3YzMwMmNkYzVjNGM4MTUwOTZhOTAzNGViYjQyYzMyZmQwNzNiMWNk
15
+ NTQ3NTQwNzJmNDM2Mzk2MDdkOWY2ZjNjMmM0NDBmNDI3NDFiZjE=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redis_logstash.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Marek Piechocki
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # RedisLogstash
2
+
3
+ Ruby logger that writes directly to LogStash via redis server
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'redis_logstash'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install redis_logstash
18
+
19
+ ## Usage
20
+
21
+ Run rails g redis_logstash to generate redis_logstash.yml config file.
22
+ Then set your redis credentials
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it ( http://github.com/<my-github-username>/redis_logstash/fork )
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ class RedisLogstashGenerator < Rails::Generators::Base
2
+
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ desc 'Creating config file for redis logstash'
6
+ def config
7
+ template "redis_logstash.yml", 'config/redis_logstash.yml'
8
+ end
9
+
10
+ end
@@ -0,0 +1,7 @@
1
+ development:
2
+ redis:
3
+ host: 'localhost'
4
+ port: 6379
5
+ password: ''
6
+ key: 'logstash'
7
+ type: 'rails-custom-logs'
@@ -0,0 +1,44 @@
1
+ module RedisLogstash
2
+ module ActionControllerExt
3
+
4
+ def redis_logstash
5
+
6
+ original_params = get_original_params
7
+ original_flash = get_original_flash
8
+ original_headers = request.headers.to_s
9
+
10
+ yield
11
+
12
+ begin
13
+ custom_logs = {
14
+ controller: params[:controller],
15
+ action: params[:action],
16
+ email: try_current_user_email,
17
+ params: original_params,
18
+ flash: original_flash,
19
+ headers: original_headers,
20
+ response_code: response.status,
21
+ response_message: response.message
22
+ }
23
+ RedisLogstash::Logger.write(custom_logs)
24
+ rescue
25
+ Rails.logger.info "Custom Logs not saved: #{custom_logs.to_json}"
26
+ end
27
+
28
+ end
29
+
30
+ def try_current_user_email
31
+ current_user.email rescue ''
32
+ end
33
+
34
+ def get_original_params
35
+ path_params = request.path_parameters
36
+ request.params.clone.except(*path_params.keys)
37
+ end
38
+
39
+ def get_original_flash
40
+ request.flash.clone
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ module RedisLogstash
2
+ class Logger
3
+ class << self
4
+
5
+ def write(hash)
6
+ Socket.write(hash)
7
+ end
8
+
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,16 @@
1
+ module RedisLogstash
2
+ class ParseConfig
3
+
4
+ @@config = nil
5
+
6
+ class << self
7
+
8
+ def get
9
+ @@config ||= YAML.load_file('config/redis_logstash.yml')[Rails.env].with_indifferent_access
10
+ end
11
+
12
+ end
13
+
14
+
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module RedisLogstash
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'redis'
2
+
3
+ require "redis_logstash/version"
4
+ require 'redis_logstash/logger'
5
+ require 'redis_logstash/socket'
6
+ require 'redis_logstash/parse_config'
7
+ require 'redis_logstash/action_controller_ext'
8
+
9
+
10
+ ActionController::Base.send :include, RedisLogstash::ActionControllerExt
11
+ ActionController::Base.send :around_filter, :redis_logstash
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'redis_logstash/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "redis_logstash"
10
+ spec.version = RedisLogstash::VERSION
11
+ spec.authors = ["Marek Piechocki"]
12
+ spec.email = ["work@marek-piechocki.pl"]
13
+ spec.summary = "Ruby logger that writes directly to LogStash via redis server"
14
+ spec.description = "LogStash Logger for ruby"
15
+ spec.homepage = ""
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_dependency "redis"
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis_logstash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marek Piechocki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: redis
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: LogStash Logger for ruby
56
+ email:
57
+ - work@marek-piechocki.pl
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/generators/redis_logstash_generator.rb
68
+ - lib/generators/templates/redis_logstash.yml
69
+ - lib/redis_logstash.rb
70
+ - lib/redis_logstash/action_controller_ext.rb
71
+ - lib/redis_logstash/logger.rb
72
+ - lib/redis_logstash/parse_config.rb
73
+ - lib/redis_logstash/version.rb
74
+ - redis_logstash.gemspec
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.1
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Ruby logger that writes directly to LogStash via redis server
99
+ test_files: []