tail-cf-plugin 0.0.21.pre → 0.0.22.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/tail-cf-plugin/loggregator_client.rb +38 -3
- data/lib/tail-cf-plugin/plugin.rb +1 -1
- metadata +4 -12
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjZlZDcyYjI0YjBkMGExNDRhYjY2MjQ2YzQzODliMWFmZDZmMzZmNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTI5YjkzNWU0ODJlNjRmZGEyN2JmMWFlODc5MTM0ZTBiNzVmYWM2NQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzIyMzY3MzE5NDQ4MTkwNDkxZTE4MjNjN2M1Njg5ZDdkODUxYTBjNWQxNjU1
|
10
|
+
ZTBjMWQzOWIxNDcxZTBhMzQ3MTNiNWZlNWJkMDJmNjYyMDI1M2NjM2E0Mjdl
|
11
|
+
MzhiZWU0NTg3NDZhZGFmOTViOWFmYzAwMTljZDJlNTRkODg0NDQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2M1NDE3ZGMyZjExYzJhMjAwYmQ1Njc5ZWFhNTczOTlkZGVhZDhiMWIzOGMy
|
14
|
+
Zjc3MjRkZDkzYTI1NDRiMzk0ZGY2ZDEyOTQ1MWM4Y2RhOTY0MWU4YWRjYzMz
|
15
|
+
ZDdmYzdkZjVmNjhhNTM1OWE1MDU4NGQ0YjE1M2MyMDA4MjI3MmQ=
|
@@ -5,14 +5,18 @@ require 'uri'
|
|
5
5
|
|
6
6
|
module TailCfPlugin
|
7
7
|
class LoggregatorClient
|
8
|
-
|
8
|
+
include CFoundry::TraceHelpers
|
9
|
+
|
10
|
+
def initialize(loggregator_host, user_token, output, trace)
|
9
11
|
@output = output
|
10
12
|
@loggregator_host = loggregator_host
|
11
13
|
@user_token = user_token
|
14
|
+
@trace = trace
|
12
15
|
end
|
13
16
|
|
14
17
|
def listen(query_params)
|
15
18
|
websocket_address = "wss://#{loggregator_host}:4443/tail/?#{hash_to_query(query_params)}"
|
19
|
+
output.puts "websocket_address: #{websocket_address}" if trace
|
16
20
|
|
17
21
|
EM.run {
|
18
22
|
ws = Faye::WebSocket::Client.new(websocket_address, nil, :headers => {"Origin" => "http://localhost", "Authorization" => user_token})
|
@@ -31,6 +35,7 @@ module TailCfPlugin
|
|
31
35
|
|
32
36
|
ws.on :error do |event|
|
33
37
|
output.puts("Server error")
|
38
|
+
output.puts(event.data.inspect) if trace
|
34
39
|
end
|
35
40
|
|
36
41
|
ws.on :close do |event|
|
@@ -51,6 +56,16 @@ module TailCfPlugin
|
|
51
56
|
request = Net::HTTP::Get.new(uri.request_uri)
|
52
57
|
request['Authorization'] = user_token
|
53
58
|
|
59
|
+
if trace
|
60
|
+
request_hash = {
|
61
|
+
:url => uri.request_uri,
|
62
|
+
:method => "GET",
|
63
|
+
:headers => sane_headers(request),
|
64
|
+
:body => ""
|
65
|
+
}
|
66
|
+
output.puts(request_trace(request_hash))
|
67
|
+
end
|
68
|
+
|
54
69
|
response = http.request(request)
|
55
70
|
|
56
71
|
return [] unless response.code == "200"
|
@@ -63,19 +78,39 @@ module TailCfPlugin
|
|
63
78
|
msg = LogMessage.decode(record)
|
64
79
|
messages << msg
|
65
80
|
end
|
81
|
+
|
82
|
+
if trace
|
83
|
+
response_hash = {
|
84
|
+
:headers => sane_headers(response),
|
85
|
+
:status => response.code,
|
86
|
+
:body => messages
|
87
|
+
}
|
88
|
+
output.puts(response_trace(response_hash))
|
89
|
+
end
|
90
|
+
|
66
91
|
messages
|
67
92
|
end
|
68
93
|
|
69
94
|
private
|
70
95
|
|
96
|
+
def sane_headers(obj)
|
97
|
+
hds = {}
|
98
|
+
|
99
|
+
obj.each_header do |k, v|
|
100
|
+
hds[k] = v
|
101
|
+
end
|
102
|
+
|
103
|
+
hds
|
104
|
+
end
|
105
|
+
|
71
106
|
def keep_alive_interval
|
72
107
|
25
|
73
108
|
end
|
74
109
|
|
75
110
|
def hash_to_query(hash)
|
76
|
-
return URI.encode(hash.map{|k,v| "#{k}=#{v}"}.join("&"))
|
111
|
+
return URI.encode(hash.map { |k, v| "#{k}=#{v}" }.join("&"))
|
77
112
|
end
|
78
113
|
|
79
|
-
attr_reader :output, :loggregator_host, :user_token
|
114
|
+
attr_reader :output, :loggregator_host, :user_token, :trace
|
80
115
|
end
|
81
116
|
end
|
@@ -30,7 +30,7 @@ module TailCfPlugin
|
|
30
30
|
fail "Please provide an application to log."
|
31
31
|
end
|
32
32
|
|
33
|
-
loggregator_client = LoggregatorClient.new(loggregator_host, client.token.auth_header, STDOUT)
|
33
|
+
loggregator_client = LoggregatorClient.new(loggregator_host, client.token.auth_header, STDOUT, input[:trace])
|
34
34
|
|
35
35
|
if input[:recent]
|
36
36
|
loggregator_client.dump_messages(log_target.query_params).each do |m|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tail-cf-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease: 7
|
4
|
+
version: 0.0.22.pre
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Pivotal
|
@@ -14,7 +13,6 @@ dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: cf
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -25,7 +23,6 @@ dependencies:
|
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
@@ -36,7 +33,6 @@ dependencies:
|
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: faye-websocket
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ~>
|
42
38
|
- !ruby/object:Gem::Version
|
@@ -44,7 +40,6 @@ dependencies:
|
|
44
40
|
type: :runtime
|
45
41
|
prerelease: false
|
46
42
|
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
43
|
requirements:
|
49
44
|
- - ~>
|
50
45
|
- !ruby/object:Gem::Version
|
@@ -52,7 +47,6 @@ dependencies:
|
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
48
|
name: beefcake
|
54
49
|
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
51
|
- - ~>
|
58
52
|
- !ruby/object:Gem::Version
|
@@ -60,7 +54,6 @@ dependencies:
|
|
60
54
|
type: :runtime
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
57
|
requirements:
|
65
58
|
- - ~>
|
66
59
|
- !ruby/object:Gem::Version
|
@@ -82,27 +75,26 @@ files:
|
|
82
75
|
homepage: http://github.com/cloudfoundry/tail-cf-plugin
|
83
76
|
licenses:
|
84
77
|
- Apache 2.0
|
78
|
+
metadata: {}
|
85
79
|
post_install_message:
|
86
80
|
rdoc_options: []
|
87
81
|
require_paths:
|
88
82
|
- lib
|
89
83
|
- vendor
|
90
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
85
|
requirements:
|
93
86
|
- - ! '>='
|
94
87
|
- !ruby/object:Gem::Version
|
95
88
|
version: 1.9.3
|
96
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
90
|
requirements:
|
99
91
|
- - ! '>'
|
100
92
|
- !ruby/object:Gem::Version
|
101
93
|
version: 1.3.1
|
102
94
|
requirements: []
|
103
95
|
rubyforge_project:
|
104
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.0.6
|
105
97
|
signing_key:
|
106
|
-
specification_version:
|
98
|
+
specification_version: 4
|
107
99
|
summary: CF Tail
|
108
100
|
test_files: []
|