loggregator_messages 0.0.3.pre → 0.0.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/loggregator_messages/log_message_extender.rb +12 -0
- data/loggregator_messages.gemspec +1 -1
- data/spec/log_message_extender_spec.rb +45 -0
- metadata +2 -3
- data/Gemfile.lock +0 -27
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -10,4 +10,16 @@ class LogMessage
|
|
10
10
|
SourceType::DEA => 'CF[DEA]',
|
11
11
|
SourceType::WARDEN_CONTAINER => 'App',}[source_type]
|
12
12
|
end
|
13
|
+
|
14
|
+
def timestamp=(timestamp)
|
15
|
+
timestamp ||= Time.now
|
16
|
+
t = timestamp.is_a?(Time) ? timestamp : Time.at(timestamp.to_f)
|
17
|
+
@timestamp = (t.tv_sec * 1000000000) + t.tv_nsec
|
18
|
+
end
|
19
|
+
|
20
|
+
def time
|
21
|
+
num_secs = @timestamp / 1000000000
|
22
|
+
fractional_usecs = (@timestamp % 1000000000).to_f / 1000
|
23
|
+
Time.at(num_secs, fractional_usecs)
|
24
|
+
end
|
13
25
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "loggregator_messages"
|
5
|
-
spec.version = '0.0.
|
5
|
+
spec.version = '0.0.4.pre'
|
6
6
|
spec.authors = ["Pivotal"]
|
7
7
|
spec.email = ["cf-eng@pivotallabs.com"]
|
8
8
|
spec.description = "Library for all of the protocol buffer messages."
|
@@ -86,4 +86,49 @@ describe LogMessage do
|
|
86
86
|
expect(msg.source_type_name).to eq("App")
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
describe "#timestamp=" do
|
91
|
+
it "defaults to Time.now" do
|
92
|
+
msg = LogMessage.new
|
93
|
+
|
94
|
+
expect(Time.at(msg.timestamp/1000000000.0)).to be_within(0.5).of(Time.now)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "takes a time object" do
|
98
|
+
msg = LogMessage.new
|
99
|
+
msg.timestamp = Time.utc(2010, 1, 20, 19, 18, 17.654321011)
|
100
|
+
|
101
|
+
expect(msg.timestamp).to eq 1264015097654321011
|
102
|
+
end
|
103
|
+
|
104
|
+
it "takes a time in seconds since the epoch" do
|
105
|
+
msg = LogMessage.new
|
106
|
+
msg.timestamp = 1379087263
|
107
|
+
|
108
|
+
expect(msg.timestamp).to eq 1379087263000000000
|
109
|
+
end
|
110
|
+
|
111
|
+
it "takes a time in fractional seconds since the epoch" do
|
112
|
+
msg = LogMessage.new
|
113
|
+
msg.timestamp = 1379087263.654321
|
114
|
+
|
115
|
+
expect(msg.timestamp).to eq 1379087263654320955
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#time" do
|
120
|
+
it "returns a time object" do
|
121
|
+
msg = LogMessage.new
|
122
|
+
msg.timestamp = 1379087263
|
123
|
+
|
124
|
+
expect(msg.time).to be_a Time
|
125
|
+
end
|
126
|
+
|
127
|
+
it "returns a time object with nanosecond precision" do
|
128
|
+
msg = LogMessage.new
|
129
|
+
msg.timestamp = Time.utc(2010, 1, 20, 19, 18, 17.654321011)
|
130
|
+
|
131
|
+
expect(msg.time.tv_nsec).to eq 654321011
|
132
|
+
end
|
133
|
+
end
|
89
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggregator_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beefcake
|
@@ -52,7 +52,6 @@ extra_rdoc_files: []
|
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
54
|
- Gemfile
|
55
|
-
- Gemfile.lock
|
56
55
|
- LICENSE
|
57
56
|
- README.md
|
58
57
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
loggregator_messages (0.0.3.pre)
|
5
|
-
beefcake (~> 0.3.7)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
beefcake (0.3.7)
|
11
|
-
diff-lcs (1.2.4)
|
12
|
-
rspec (2.14.1)
|
13
|
-
rspec-core (~> 2.14.0)
|
14
|
-
rspec-expectations (~> 2.14.0)
|
15
|
-
rspec-mocks (~> 2.14.0)
|
16
|
-
rspec-core (2.14.5)
|
17
|
-
rspec-expectations (2.14.2)
|
18
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
19
|
-
rspec-mocks (2.14.3)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
ruby
|
23
|
-
|
24
|
-
DEPENDENCIES
|
25
|
-
bundler (~> 1.3)
|
26
|
-
loggregator_messages!
|
27
|
-
rspec (~> 2.14.0)
|