log_simulator 0.1.3 → 0.2.0
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.
- checksums.yaml +4 -4
- data/bin/simulate +6 -2
- data/lib/log_simulator/version.rb +1 -1
- data/lib/peak_log_simulator.rb +11 -4
- data/log_simulator.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e46a3e2ce97f595adbb932c47fb2911bcafa353
|
4
|
+
data.tar.gz: ebe48704df22d97935621be3ece3225406a0e32e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1da4b658e560f0405f385ec021ac3b82e874f75c1cde22c2e508aca9447c59a7adc888b28738a51a9248c289d8b8a8be6d3d2c30791d0a9757b0139de4abf3e9
|
7
|
+
data.tar.gz: 705d4c696d1330b8f2f2017df05dcf53d0e923c69f9de49ed76594e2e919e00a99f17d7e25c2f0343e04bc6452ff1f1ae3f926f170f193343a39d9dd5a402664
|
data/bin/simulate
CHANGED
@@ -6,7 +6,7 @@ require 'peak_log_simulator'
|
|
6
6
|
require 'resolve'
|
7
7
|
require 'socket_connetion'
|
8
8
|
|
9
|
-
options={:filepath => nil ,:timescale => 1.0}
|
9
|
+
options={:filepath => nil ,:timescale => 1.0, :pretty => false}
|
10
10
|
|
11
11
|
opts = OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: simulate [logfile path] [options]"
|
@@ -15,6 +15,10 @@ opts = OptionParser.new do |opts|
|
|
15
15
|
options[:timescale] = time
|
16
16
|
end
|
17
17
|
|
18
|
+
opts.on('-p','--pretty','Pretty Log Messages') do
|
19
|
+
options[:pretty] = true
|
20
|
+
end
|
21
|
+
|
18
22
|
opts.on('-v','--version','Version') {puts LogSimulator::VERSION; exit}
|
19
23
|
|
20
24
|
opts.on_tail('-h', '--help', 'Show this message') { puts opts; exit }
|
@@ -37,7 +41,7 @@ LogSimulator::Resolver.select_target(2.0) do |target|
|
|
37
41
|
socket_connection = LogSimulator::SocketConnetion.new(target.target_name,target.port)
|
38
42
|
|
39
43
|
unless options[:filepath].nil?
|
40
|
-
LogSimulator::PeakLogSimulator.start(socket_connection.socket,options[:filepath],options[:timescale]) do |success|
|
44
|
+
LogSimulator::PeakLogSimulator.start(socket_connection.socket,options[:filepath],options[:timescale],options[:pretty]) do |success|
|
41
45
|
while true #TODO: make it DRY
|
42
46
|
print '>'
|
43
47
|
message = gets.chomp
|
data/lib/peak_log_simulator.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'date'
|
3
|
+
require 'json-prettyprint'
|
2
4
|
|
3
5
|
module LogSimulator
|
4
6
|
class PeakLogSimulator
|
5
7
|
|
6
|
-
def self.start(socket,filepath,timescale)
|
8
|
+
def self.start(socket,filepath,timescale,pretty)
|
7
9
|
path = File.expand_path(filepath)
|
8
10
|
puts 'Opening log file at path: ' + path
|
9
11
|
|
@@ -23,7 +25,7 @@ module LogSimulator
|
|
23
25
|
if socket != nil
|
24
26
|
socket.puts message
|
25
27
|
end
|
26
|
-
puts '<' + message
|
28
|
+
puts '<' + (pretty ? (JSON::PrettyPrint.prettify(message)) : message)
|
27
29
|
time = _time
|
28
30
|
end
|
29
31
|
end
|
@@ -33,8 +35,13 @@ module LogSimulator
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def self.timestamp_parse (line)
|
36
|
-
line.scan(/N\|(
|
37
|
-
|
38
|
+
line.scan(/N\|(.+)\|RECEIVE << (.*)/) do |timestamp,message|
|
39
|
+
begin
|
40
|
+
date = DateTime.parse(timestamp)
|
41
|
+
yield date.to_time.utc.to_i,message
|
42
|
+
rescue
|
43
|
+
yield timestamp.to_i,message
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
data/log_simulator.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "dnssd", "~>2.0"
|
22
|
+
spec.add_runtime_dependency "json-prettyprint"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
24
|
spec.add_development_dependency "rake"
|
24
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_simulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ogan Topkaya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dnssd
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json-prettyprint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|