loggregator_emitter 0.0.12.pre → 0.0.13.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "loggregator_messages", "~> 0.0.5.pre"
4
-
5
3
  # Specify your gem's dependencies in .gemspec
6
4
  gemspec
@@ -1,16 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- loggregator_emitter (0.0.12.pre)
5
- loggregator_messages (~> 0.0.1.pre)
4
+ loggregator_emitter (0.0.13.pre)
5
+ beefcake (~> 0.3.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  beefcake (0.3.7)
11
11
  diff-lcs (1.2.4)
12
- loggregator_messages (0.0.5.pre)
13
- beefcake (~> 0.3.7)
14
12
  rake (10.1.0)
15
13
  rspec (2.14.1)
16
14
  rspec-core (~> 2.14.0)
@@ -27,6 +25,5 @@ PLATFORMS
27
25
  DEPENDENCIES
28
26
  bundler (~> 1.3)
29
27
  loggregator_emitter!
30
- loggregator_messages (~> 0.0.5.pre)
31
28
  rake (~> 10.1.0)
32
29
  rspec (~> 2.14.1)
@@ -1 +1,3 @@
1
1
  require "loggregator_emitter/emit"
2
+ require "loggregator_messages/log_message.pb"
3
+ require "loggregator_messages/log_message_extender"
@@ -1,4 +1,3 @@
1
- require "loggregator_messages"
2
1
  require 'socket'
3
2
 
4
3
  module LoggregatorEmitter
@@ -0,0 +1,26 @@
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
+ optional :app_id, :string, 4
24
+ required :source_type, LogMessage::SourceType, 5
25
+ optional :source_id, :string, 6
26
+ 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
+ optional string app_id = 4;
21
+ required SourceType source_type = 5;
22
+ optional string source_id = 6;
23
+ }
@@ -0,0 +1,23 @@
1
+ class LogMessage
2
+ def message_type_name
3
+ {MessageType::OUT => 'STDOUT', MessageType::ERR => 'STDERR'}[message_type]
4
+ end
5
+
6
+ def source_type_name
7
+ {SourceType::CLOUD_CONTROLLER => 'CF[CC]',
8
+ SourceType::ROUTER => 'CF[Router]',
9
+ SourceType::UAA => 'CF[UAA]',
10
+ SourceType::DEA => 'CF[DEA]',
11
+ SourceType::WARDEN_CONTAINER => 'App',}[source_type]
12
+ end
13
+
14
+ def time=(time)
15
+ self.timestamp = (time.tv_sec * 1000000000) + time.tv_nsec
16
+ end
17
+
18
+ def time
19
+ num_secs = @timestamp / 1000000000
20
+ fractional_usecs = (@timestamp % 1000000000).to_f / 1000
21
+ Time.at(num_secs, fractional_usecs)
22
+ end
23
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "loggregator_emitter"
5
- spec.version = '0.0.12.pre'
5
+ spec.version = '0.0.13.pre'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library to emit data to Loggregator"
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
19
19
 
20
- spec.add_dependency "loggregator_messages", "~> 0.0.1.pre"
20
+ spec.add_dependency "beefcake", "~> 0.3.7"
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake", "~> 10.1.0"
@@ -1,5 +1,5 @@
1
1
  require 'support/fake_loggregator_server'
2
- require 'loggregator_emitter/emit'
2
+ require 'loggregator_emitter'
3
3
 
4
4
  describe LoggregatorEmitter do
5
5
 
@@ -0,0 +1,114 @@
1
+ require "rspec"
2
+ require "loggregator_emitter"
3
+
4
+ describe LogMessage do
5
+ describe "#message_type_name" do
6
+ it "returns STDOUT for type == 1" do
7
+ msg = LogMessage.new(
8
+ {
9
+ :message => "thesearebytes",
10
+ :message_type => 1,
11
+ :timestamp => 3,
12
+ :source_type => 3
13
+ })
14
+
15
+ expect(msg.message_type_name).to eq("STDOUT")
16
+ end
17
+
18
+ it "returns STDERR for type == 2" do
19
+ msg = LogMessage.new(
20
+ {
21
+ :message => "thesearebytes",
22
+ :message_type => 2,
23
+ :timestamp => 3,
24
+ :source_type => 3
25
+ })
26
+
27
+ expect(msg.message_type_name).to eq("STDERR")
28
+ end
29
+ end
30
+
31
+ describe "#source_type_name" do
32
+ it "returns CloudController for type == 1" do
33
+ msg = LogMessage.new(
34
+ {
35
+ :message => "thesearebytes",
36
+ :message_type => 1,
37
+ :timestamp => 3,
38
+ :source_type => 1
39
+ })
40
+
41
+ expect(msg.source_type_name).to eq("CF[CC]")
42
+ end
43
+
44
+ it "returns Router for type == 2" do
45
+ msg = LogMessage.new(
46
+ {
47
+ :message => "thesearebytes",
48
+ :message_type => 2,
49
+ :timestamp => 3,
50
+ :source_type => 2
51
+ })
52
+
53
+ expect(msg.source_type_name).to eq("CF[Router]")
54
+ end
55
+ it "returns UAA for type == 3" do
56
+ msg = LogMessage.new(
57
+ {
58
+ :message => "thesearebytes",
59
+ :message_type => 2,
60
+ :timestamp => 3,
61
+ :source_type => 3
62
+ })
63
+
64
+ expect(msg.source_type_name).to eq("CF[UAA]")
65
+ end
66
+ it "returns DEA for type == 4" do
67
+ msg = LogMessage.new(
68
+ {
69
+ :message => "thesearebytes",
70
+ :message_type => 2,
71
+ :timestamp => 3,
72
+ :source_type => 4
73
+ })
74
+
75
+ expect(msg.source_type_name).to eq("CF[DEA]")
76
+ end
77
+ it "returns WardenContainer for type == 5" do
78
+ msg = LogMessage.new(
79
+ {
80
+ :message => "thesearebytes",
81
+ :message_type => 2,
82
+ :timestamp => 3,
83
+ :source_type => 5
84
+ })
85
+
86
+ expect(msg.source_type_name).to eq("App")
87
+ end
88
+ end
89
+
90
+ describe "#time=" do
91
+ it "takes a time object" do
92
+ msg = LogMessage.new
93
+ msg.time = Time.utc(2010, 1, 20, 19, 18, 17.654321011)
94
+
95
+ expect(msg.timestamp).to eq 1264015097654321011
96
+ end
97
+ end
98
+
99
+ describe "#time" do
100
+ it "returns a time object" do
101
+ msg = LogMessage.new
102
+ msg.timestamp = 1264015097654321011
103
+
104
+ expect(msg.time).to be_a Time
105
+ end
106
+
107
+ it "returns a time object with nanosecond precision" do
108
+ msg = LogMessage.new
109
+ msg.timestamp = 1264015097654321011
110
+
111
+ expect(msg.time.tv_nsec).to eq 654321011
112
+ end
113
+ end
114
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggregator_emitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12.pre
4
+ version: 0.0.13.pre
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -9,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-19 00:00:00.000000000 Z
12
+ date: 2013-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: loggregator_messages
15
+ name: beefcake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.0.1.pre
21
+ version: 0.3.7
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 0.0.1.pre
29
+ version: 0.3.7
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -91,8 +91,12 @@ files:
91
91
  - Rakefile
92
92
  - lib/loggregator_emitter.rb
93
93
  - lib/loggregator_emitter/emit.rb
94
+ - lib/loggregator_messages/log_message.pb.rb
95
+ - lib/loggregator_messages/log_message.proto
96
+ - lib/loggregator_messages/log_message_extender.rb
94
97
  - loggregator_emitter.gemspec
95
98
  - spec/loggregator_emitter/emit_spec.rb
99
+ - spec/loggregator_emitter/log_message_extender_spec.rb
96
100
  - spec/support/fake_loggregator_server.rb
97
101
  homepage: https://www.github.com/cloudfoundry/loggregator_emitter
98
102
  licenses:
@@ -121,4 +125,5 @@ specification_version: 3
121
125
  summary: Library to emit data to Loggregator
122
126
  test_files:
123
127
  - spec/loggregator_emitter/emit_spec.rb
128
+ - spec/loggregator_emitter/log_message_extender_spec.rb
124
129
  - spec/support/fake_loggregator_server.rb