tail-cf-plugin 0.0.8.pre

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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Tail-Cf-Plugin [![Build Status](https://travis-ci.org/cloudfoundry/tail-cf-plugin.png?branch=master)](https://travis-ci.org/cloudfoundry/tail-cf-plugin)
2
+
3
+ Plugin to cf command to add streaming application logs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tail-cf-plugin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tail-cf-plugin
18
+
19
+ ## Usage
20
+
21
+ After installing you can run cf tail and see your application's logs stream to the console.
22
+
23
+ ## Contributing
24
+
25
+ The Cloud Foundry team uses GitHub and accepts contributions via [pull request](https://help.github.com/articles/using-pull-requests)
26
+
27
+ Follow these steps to make a contribution to any of our open source repositories:
28
+
29
+ 1. Complete our CLA Agreement for [individuals](http://www.cloudfoundry.org/individualcontribution.pdf) or [corporations](http://www.cloudfoundry.org/corpcontribution.pdf)
30
+ 1. Set your name and email
31
+
32
+ git config --global user.name "Firstname Lastname"
33
+ git config --global user.email "your_email@youremail.com"
34
+
35
+ 1. Fork the repo
36
+ 1. Make your changes on a topic branch, commit, and push to github and open a pull request.
37
+
38
+ Once your commits are approved by Travis CI and reviewed by the core team, they will be merged.
39
+
40
+ #### Checkout
41
+
42
+ git clone git@github.com:cloudfoundry/tail-cf-plugin.git
43
+ cd tail-cf-plugin/
44
+ bundle
45
+
46
+ #### Running tests
47
+
48
+ rake
49
+
@@ -0,0 +1,35 @@
1
+ module TailCfPlugin
2
+ class LoggregatorClient
3
+ def initialize(output)
4
+ @output = output
5
+ end
6
+
7
+ def listen(loggregator_host, space_id, app_id, user_token)
8
+ websocket_address = "ws://#{loggregator_host}/tail/spaces/#{space_id}"
9
+ websocket_address += "/apps/#{app_id}" if app_id
10
+
11
+ websocket_address += "?authorization=#{URI.encode(user_token)}"
12
+
13
+ EM.run {
14
+ ws = Faye::WebSocket::Client.new(websocket_address, nil, :headers => {"Origin" => "http://localhost"})
15
+
16
+ ws.on :message do |event|
17
+ received_message = LogMessage.decode(event.data.pack("C*"))
18
+ output.puts([received_message.app_id, received_message.source_id, received_message.message_type_name, received_message.message].join(" "))
19
+ end
20
+
21
+ ws.on :error do |event|
22
+ output.puts("Server error")
23
+ end
24
+
25
+ ws.on :close do |event|
26
+ output.puts("Server dropped connection")
27
+ end
28
+ }
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :output
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ require 'cf'
2
+ require 'faye/websocket'
3
+ require 'eventmachine'
4
+
5
+ module TailCfPlugin
6
+ require 'tail-cf-plugin/loggregrator_client'
7
+ require 'log_message/log_message.pb'
8
+
9
+ class Plugin < CF::CLI
10
+ include LoginRequirements
11
+
12
+ desc "Tail a CF application's logs"
13
+ group :apps
14
+ input :loggregator_host, :argument => :required, :desc => "The ip:port of the loggregator"
15
+ input :app, :desc => "App to tail logs from", :argument => :optional, :from_given => by_name(:app)
16
+ input :space, :desc => "App to tail logs from", :argument => :optional, :from_given => by_name(:space)
17
+
18
+ def tail
19
+
20
+ raise "Missing an app or space" unless input[:app] || input[:space]
21
+
22
+ space_guid = (input[:space] && input[:space].guid) || input[:app].space_guid
23
+ app_guid = input[:app] && input[:app].guid
24
+
25
+ loggregrator_client = LoggregatorClient.new(STDOUT)
26
+ loggregrator_client.listen(input[:loggregator_host], space_guid, app_guid, client.token.auth_header)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ ## Generated from log_message.proto for logMessage
2
+ require "beefcake"
3
+
4
+
5
+ class LogMessage
6
+ include Beefcake::Message
7
+
8
+ module MessageType
9
+ OUT = 1
10
+ ERR = 2
11
+ end
12
+ module SourceType
13
+ CLOUD_CONTROLLER = 1
14
+ ROUTER = 2
15
+ UAA = 3
16
+ DEA = 4
17
+ WARDEN_CONTAINER = 5
18
+ end
19
+
20
+ required :message, :bytes, 1
21
+ required :message_type, LogMessage::MessageType, 2
22
+ required :timestamp, :sint64, 3
23
+ required :app_id, :string, 4
24
+ required :source_type, LogMessage::SourceType, 5
25
+ optional :source_id, :string, 6
26
+
27
+ def message_type_name
28
+ {MessageType::OUT => 'STDOUT', MessageType::ERR => 'STDERR'}[message_type]
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ package logMessage;
2
+
3
+ message LogMessage {
4
+ enum MessageType {
5
+ OUT = 1;
6
+ ERR = 2;
7
+ }
8
+
9
+ enum SourceType {
10
+ CLOUD_CONTROLLER = 1;
11
+ ROUTER = 2;
12
+ UAA = 3;
13
+ DEA = 4;
14
+ WARDEN_CONTAINER = 5;
15
+ }
16
+
17
+ required bytes message = 1;
18
+ required MessageType message_type = 2;
19
+ required sint64 timestamp = 3;
20
+ required string app_id = 4;
21
+ required SourceType source_type = 5;
22
+ optional string source_id = 6;
23
+ }
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tail-cf-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Pivotal
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cf
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: faye-websocket
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.6.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: beefcake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.7
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.7
62
+ description: CF command line tool to tail CF Application Logs
63
+ email:
64
+ - vcap-dev@googlegroups.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/tail-cf-plugin/loggregrator_client.rb
70
+ - lib/tail-cf-plugin/plugin.rb
71
+ - vendor/log_message/log_message.pb.rb
72
+ - vendor/log_message/log_message.proto
73
+ - README.md
74
+ homepage: http://github.com/cloudfoundry/tail-cf-plugin
75
+ licenses:
76
+ - Apache 2.0
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ - vendor
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 1.9.3
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>'
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.1
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.25
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: CF Tail
100
+ test_files: []