rackstash 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ require 'rackstash/runner'
2
+
3
+ require 'minitest/mock'
4
+ require 'stringio'
5
+ require 'json'
6
+
7
+ describe Rackstash::Runner do
8
+ def capture_json(*args)
9
+ out, err = capture_io do
10
+ Rackstash::Runner.start(args)
11
+ end
12
+ @json = JSON.parse(out.lines.to_a.last)
13
+ end
14
+
15
+ def json
16
+ @json
17
+ end
18
+
19
+ def stdin(*data)
20
+ @stdin_original = $stdin
21
+ $stdin = Struct.new(:data) do
22
+ def each_line(&block)
23
+ data.each(&block)
24
+ end
25
+ end.new(data)
26
+ end
27
+
28
+ after do
29
+ if @stdin_original
30
+ $stdin = @stdin_original
31
+ @stdin_original = nil
32
+ end
33
+ end
34
+
35
+ describe "#capture" do
36
+ it "creates a log entry on STDOUT" do
37
+ stdin "Hello World"
38
+ capture_json "capture"
39
+
40
+ json["@message"].must_equal " [INFO] Hello World"
41
+ json["@source"].must_equal nil
42
+ json["@tags"].must_equal []
43
+ json["@fields"].keys.sort.must_equal %w[log_id pid]
44
+ # Timestamp is less than 2 seconds ago
45
+ timestamp_range = ((Time.now-2)..Time.now)
46
+ method = timestamp_range.respond_to?(:cover?) ? :cover? : :===
47
+ timestamp_range.must_be method, Time.parse(json["@timestamp"])
48
+ end
49
+
50
+ it "accepts a custom source" do
51
+ stdin "Hello World"
52
+ capture_json "capture", "--source", "STDIN"
53
+
54
+ json["@source"].must_equal "STDIN"
55
+ end
56
+
57
+ it "accepts custom fields" do
58
+ stdin "Hello World"
59
+ capture_json "capture", "--fields", "key1:value1", "key2:value2"
60
+
61
+ json["@fields"].keys.sort.must_equal %w[key1 key2 log_id pid]
62
+ json["@fields"]["key1"].must_equal "value1"
63
+ json["@fields"]["key2"].must_equal "value2"
64
+ end
65
+
66
+ it "can overwrite automatically filled fields" do
67
+ stdin "Hello World"
68
+ capture_json "capture", "--fields", "pid:foo"
69
+
70
+ json["@fields"]["pid"].wont_equal Process.pid
71
+ json["@fields"]["pid"].must_equal "foo"
72
+ end
73
+
74
+ it "accepts custom tags" do
75
+ stdin "Hello World"
76
+ capture_json "capture", "--tags=foo", "bar", "baz"
77
+
78
+ json["@tags"].must_equal %w[foo bar baz]
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require 'bundler/setup'
4
+ Bundler.require :default
5
+
6
+ begin
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+ rescue LoadError
10
+ # Coveralls is only available for some rubies...
11
+ end
12
+
13
+ require 'minitest/autorun'
metadata CHANGED
@@ -1,64 +1,137 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Holger Just
7
+ - Holger Just, Planio GmbH
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: logstash-event
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: 1.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: thor
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
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
20
62
  type: :development
21
63
  prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
- - - "~>"
66
+ - - ">="
25
67
  - !ruby/object:Gem::Version
26
- version: '1.11'
68
+ version: '0'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rake
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
- - - "~>"
73
+ - - ">="
32
74
  - !ruby/object:Gem::Version
33
- version: '10.0'
75
+ version: '0'
34
76
  type: :development
35
77
  prerelease: false
36
78
  version_requirements: !ruby/object:Gem::Requirement
37
79
  requirements:
38
- - - "~>"
80
+ - - ">="
39
81
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description: This is just a placeholder for now. Please have a look at https://github.com/meineerde/rackstash
42
- for any progress on releasing this gem.
43
- email:
44
- executables: []
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Making Rack and Rails logs useful
98
+ email:
99
+ - holger@plan.io
100
+ executables:
101
+ - rackstash
45
102
  extensions: []
46
103
  extra_rdoc_files: []
47
104
  files:
48
105
  - ".gitignore"
49
- - CODE_OF_CONDUCT.md
106
+ - ".travis.yml"
50
107
  - Gemfile
51
108
  - LICENSE.txt
52
109
  - README.md
53
110
  - Rakefile
54
- - bin/console
55
- - bin/setup
111
+ - bin/rackstash
56
112
  - lib/rackstash.rb
113
+ - lib/rackstash/buffered_logger.rb
114
+ - lib/rackstash/framework/base.rb
115
+ - lib/rackstash/framework/rack.rb
116
+ - lib/rackstash/framework/rails2.rb
117
+ - lib/rackstash/framework/rails3.rb
118
+ - lib/rackstash/log_middleware.rb
119
+ - lib/rackstash/log_severity.rb
120
+ - lib/rackstash/log_subscriber.rb
121
+ - lib/rackstash/rails_ext/action_controller.rb
122
+ - lib/rackstash/rails_ext/initializer.rb
123
+ - lib/rackstash/railtie.rb
124
+ - lib/rackstash/runner.rb
57
125
  - lib/rackstash/version.rb
126
+ - lib/tasks/rackstash.rb
58
127
  - rackstash.gemspec
59
- homepage: https://github.com/meineerde/rackstash
60
- licenses:
61
- - MIT
128
+ - test/buffered_logger_test.rb
129
+ - test/log_subscriber_test.rb
130
+ - test/rackstash_test.rb
131
+ - test/runner_test.rb
132
+ - test/test_helper.rb
133
+ homepage: https://github.com/planio-gmbh/rackstash
134
+ licenses: []
62
135
  metadata: {}
63
136
  post_install_message:
64
137
  rdoc_options: []
@@ -68,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
141
  requirements:
69
142
  - - ">="
70
143
  - !ruby/object:Gem::Version
71
- version: 2.1.0
144
+ version: '0'
72
145
  required_rubygems_version: !ruby/object:Gem::Requirement
73
146
  requirements:
74
147
  - - ">="
@@ -76,8 +149,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
149
  version: '0'
77
150
  requirements: []
78
151
  rubyforge_project:
79
- rubygems_version: 2.4.8
152
+ rubygems_version: 2.6.13
80
153
  signing_key:
81
154
  specification_version: 4
82
- summary: This is a placeholder for now
83
- test_files: []
155
+ summary: Making Rack and Rails logs useful
156
+ test_files:
157
+ - test/buffered_logger_test.rb
158
+ - test/log_subscriber_test.rb
159
+ - test/rackstash_test.rb
160
+ - test/runner_test.rb
161
+ - test/test_helper.rb
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at hjust@meine-er.de. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rackstash"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here