logs-cf-plugin 0.0.37.pre → 0.0.38.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjU0ZWQ0Y2IwNDExMWIwM2E4MmZjYTI1NGY5ZmYxYTRkODBlOGY1ZQ==
4
+ ZjE3ZDZkYmZmMGY0YzljNGMxNDFjNDcxY2Y4YmVkY2MzNDU5NmNiMw==
5
5
  data.tar.gz: !binary |-
6
- NjlkNzViMTA4OGNjNDQ5ZGY2NDExNTExZWJhY2E2ZDMzOGQxOTRmOA==
6
+ ZmUxMWYxM2MwNzg3NGIxZjk3YTA2OGJlNGE2YWVmM2VjMWZkODUyZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjgxZjBjN2Y4MDU3NTJkZWFiMDU0MjZiNGM2NjliZGYxMmQwZWQzNTg2NWNh
10
- MDJiOTk0M2ZlYjcyYTk0ZjcyMDJlMDk4MDU2MDM4NDczYTExMWFkM2Y1ZDli
11
- NjYwNjJmZWFiMzJjNjIyZThhNzA4NjY3MGQxODZiMWM0MDI4NDA=
9
+ YTg1YWI4MzI3YjYzNWExNGZjMjhhZWIxMjVmN2Y3ZTE1ZWJmOTQ2YTkyZjMz
10
+ YzcxNTQxMjY1ZDlmYTE3ZGIzZTMyOWI1MjM1YzBhM2E2ZTk2OWNmODBlZjUy
11
+ Nzk4N2Q1ZjY3MzhkYzY4OGYzYzQ5MGU5MmIyYzhjOWYxMWNiYzM=
12
12
  data.tar.gz: !binary |-
13
- YjcwNWY1YzUwZTZhYmE5YjA5ZGY0MmI5YzZjZjk1OWFkOGU1Nzc3ZmViYThl
14
- MGJjYTIzZTU5OTA2NjQ5OTJjOTZhZWUxYzUxNDdkZmZhMTU0YTAyMGFkZTgy
15
- YTNmZDJlOTNjOGUwZmI5Y2IyNTdhOGYxN2U3OTU0M2E0YzE5MzE=
13
+ NWEwMWE3ZWFlMWViMzlkZWE1ZDRhOGY4MmJkZjI2NGQxZmQyYTZkMTZhNzVi
14
+ ODkxMDY1MzA5ZWYyNTk0OGYwN2VlYjdhYmExZDY2YTQzODkwOGMzNjc2YzE5
15
+ MmQzYjQwNmZmNDQ1NDI2OGQ1N2VjZjE3OGI4ZDFlMWQ3ZmI5YmI=
@@ -11,11 +11,11 @@ module LogsCfPlugin
11
11
  @use_ssl = use_ssl
12
12
  end
13
13
 
14
- def listen(log_target)
14
+ def listen(app)
15
15
  if use_ssl
16
- websocket_address = "wss://#{loggregator_host}:4443/tail/?#{hash_to_query(log_target.query_params)}"
16
+ websocket_address = "wss://#{loggregator_host}:4443/tail/?app=#{app.guid}"
17
17
  else
18
- websocket_address = "ws://#{loggregator_host}/tail/?#{hash_to_query(log_target.query_params)}"
18
+ websocket_address = "ws://#{loggregator_host}/tail/?app=#{app.guid}"
19
19
  end
20
20
 
21
21
  output.puts "websocket_address: #{websocket_address}" if trace
@@ -33,8 +33,8 @@ module LogsCfPlugin
33
33
  ws.on :message do |event|
34
34
  begin
35
35
  received_message = LogMessage.decode(event.data.pack("C*"))
36
- write(log_target, output, received_message)
37
- rescue Beefcake::Message::WrongTypeError, Beefcake::Message::RequiredFieldNotSetError, Beefcake::Message::InvalidValueError
36
+ write(app, output, received_message)
37
+ rescue Beefcake::Message::WrongTypeError, Beefcake::Message::RequiredFieldNotSetError, Beefcake::Message::InvalidValueError
38
38
  output.puts("Error parsing data. Please ensure your gem is the latest version.")
39
39
  ws.close
40
40
  EM.stop
@@ -63,9 +63,9 @@ module LogsCfPlugin
63
63
  }
64
64
  end
65
65
 
66
- def dump_messages(log_target)
66
+ def dump_messages(app)
67
67
  prefix = use_ssl ? 'https' : 'http'
68
- uri = URI.parse("#{prefix}://#{loggregator_host}/dump/?#{hash_to_query(log_target.query_params)}")
68
+ uri = URI.parse("#{prefix}://#{loggregator_host}/dump/?app=#{app.guid}")
69
69
  http = Net::HTTP.new(uri.host, uri.port)
70
70
  http.use_ssl = use_ssl
71
71
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -75,10 +75,10 @@ module LogsCfPlugin
75
75
 
76
76
  if trace
77
77
  request_hash = {
78
- :url => uri.request_uri,
79
- :method => "GET",
80
- :headers => sane_headers(request),
81
- :body => ""
78
+ :url => uri.request_uri,
79
+ :method => "GET",
80
+ :headers => sane_headers(request),
81
+ :body => ""
82
82
  }
83
83
  output.puts(request_trace(request_hash))
84
84
  end
@@ -92,7 +92,7 @@ module LogsCfPlugin
92
92
  output.puts("Unauthorized")
93
93
  return
94
94
  when "404"
95
- output.puts("App #{log_target.app_name} not found")
95
+ output.puts("App #{app.name} not found")
96
96
  return
97
97
  else
98
98
  output.puts("Error connecting to server #{response.code}")
@@ -110,15 +110,15 @@ module LogsCfPlugin
110
110
 
111
111
  if trace
112
112
  response_hash = {
113
- :headers => sane_headers(response),
114
- :status => response.code,
115
- :body => messages
113
+ :headers => sane_headers(response),
114
+ :status => response.code,
115
+ :body => messages
116
116
  }
117
117
  output.puts(response_trace(response_hash))
118
118
  end
119
119
 
120
120
  messages.each do |m|
121
- write(log_target, output, m)
121
+ write(app, output, m)
122
122
  end
123
123
  rescue Beefcake::Message::WrongTypeError, Beefcake::Message::RequiredFieldNotSetError, Beefcake::Message::InvalidValueError
124
124
  output.puts("Error parsing data. Please ensure your gem is the latest version.")
@@ -2,8 +2,9 @@ require "cf/cli"
2
2
 
3
3
  module MessageWriter
4
4
  include CF::Interactive
5
- def write(log_target, output, message)
6
- msg = [log_target.app_name, message.source_type_name, message.source_id, message.message_type_name, message.message].join(" ")
5
+
6
+ def write(app, output, message)
7
+ msg = [app.name, message.source_type_name, message.source_id, message.message_type_name, message.message].join(" ")
7
8
  msg = c(msg.chomp, :error) if message.message_type == LogMessage::MessageType::ERR
8
9
  output.puts(msg)
9
10
  end
@@ -5,7 +5,6 @@ require 'loggregator_messages'
5
5
  require 'uri'
6
6
 
7
7
  module LogsCfPlugin
8
- require 'logs-cf-plugin/log_target'
9
8
  require 'logs-cf-plugin/message_writer'
10
9
  require 'logs-cf-plugin/loggregator_client'
11
10
 
@@ -21,10 +20,7 @@ module LogsCfPlugin
21
20
  def logs
22
21
  client.current_organization.name # resolve org name so CC will validate AuthToken
23
22
 
24
-
25
- log_target = LogTarget.new(input[:app])
26
-
27
- unless log_target.valid?
23
+ unless input[:app]
28
24
  Mothership::Help.command_help(@@commands[:logs])
29
25
  fail "Please provide an application to log."
30
26
  end
@@ -32,9 +28,9 @@ module LogsCfPlugin
32
28
  loggregator_client = LoggregatorClient.new(loggregator_host, client.token.auth_header, STDOUT, input[:trace], use_ssl)
33
29
 
34
30
  if input[:recent]
35
- loggregator_client.dump_messages(log_target)
31
+ loggregator_client.dump_messages(input[:app])
36
32
  else
37
- loggregator_client.listen(log_target)
33
+ loggregator_client.listen(input[:app])
38
34
  end
39
35
  end
40
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logs-cf-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37.pre
4
+ version: 0.0.38.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
@@ -73,7 +73,6 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - lib/logs-cf-plugin/log_target.rb
77
76
  - lib/logs-cf-plugin/loggregator_client.rb
78
77
  - lib/logs-cf-plugin/message_writer.rb
79
78
  - lib/logs-cf-plugin/plugin.rb
@@ -1,29 +0,0 @@
1
- module LogsCfPlugin
2
- class LogTarget
3
- def initialize(app)
4
- @app = app
5
- end
6
-
7
- def valid?
8
- !app_id.nil?
9
- end
10
-
11
- def query_params
12
- {app: app_id}
13
- end
14
-
15
- def app_id
16
- @app.try(:guid)
17
- end
18
-
19
- def app_name
20
- @app.try(:name)
21
- end
22
-
23
- private
24
-
25
- def target
26
- :app if app_id
27
- end
28
- end
29
- end