dummy_log_generator 0.2.0 → 0.2.1
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/CHANGELOG.md +6 -0
- data/README.md +10 -10
- data/example/input.conf +6 -0
- data/example/input.txt +10 -0
- data/example/message.conf +5 -0
- data/{dummy_log_generator.conf → example/sample.conf} +1 -1
- data/lib/dummy_log_generator/cli.rb +10 -7
- data/lib/dummy_log_generator/dsl.rb +1 -0
- data/lib/dummy_log_generator/generator.rb +6 -5
- data/lib/dummy_log_generator/setting.rb +2 -2
- data/lib/dummy_log_generator/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 760e8bbf26f9bfcc32494aed36086f062ee5fe28
|
4
|
+
data.tar.gz: 64cfb639cc486f51dcf403020b5085c5dc9216ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0958e911b83801d2b133b2d25689e930f3dc3c0771ba87f7fca57e45a25599fa6bed97d5f8aad6ee448e5cd4a4dbb3dcd0f766717c77a0cbd7cd6b7cae5bf8c3
|
7
|
+
data.tar.gz: 6ca6c0a19b9740d2b8063094427eb6acc723d5b41bc84957bcdce6c2d83d9b6246f65e58ecc37b58babc5f0d3fc292d5c4920020215645bbb510f0f50fd01395
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,8 +47,8 @@ configure 'sample' do
|
|
47
47
|
rate 500
|
48
48
|
delimiter "\t"
|
49
49
|
labeled true
|
50
|
-
field :id, type: :integer, countup: true
|
51
|
-
field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random:
|
50
|
+
field :id, type: :integer, countup: true, format: "%04d"
|
51
|
+
field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: false
|
52
52
|
field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
|
53
53
|
field :method, type: :string, any: %w[GET POST PUT]
|
54
54
|
field :uri, type: :string, any: %w[/api/v1/people /api/v1/textdata /api/v1/messages]
|
@@ -66,9 +66,9 @@ $ dummy_log_genrator -c dummy_log_generator.conf
|
|
66
66
|
Outputs to the `dummy.log` (specified by `output` parameter) file like:
|
67
67
|
|
68
68
|
```
|
69
|
-
id:
|
70
|
-
id:
|
71
|
-
id:
|
69
|
+
id:0422 time:[2013-11-19 02:34:58] level:INFO method:POST uri:/api/v1/textdata reqtime:3.9726677258569842 foobar:LFK6XV1N
|
70
|
+
id:0423 time:[2013-11-19 02:34:58] level:DEBUG method:GET uri:/api/v1/people reqtime:0.49912949125272277 foobar:DcOYrONH
|
71
|
+
id:0424 time:[2013-11-19 02:34:58] level:WARN method:POST uri:/api/v1/textdata reqtime:2.930590441869852 foobar:XEZ5bQsh
|
72
72
|
```
|
73
73
|
|
74
74
|
### Configuration Parameters
|
@@ -97,15 +97,15 @@ Following parameters in the configuration file are available:
|
|
97
97
|
|
98
98
|
* field
|
99
99
|
|
100
|
-
Define data fields to generate
|
100
|
+
Define data fields to generate. `message` and `field` are ignored.
|
101
101
|
|
102
|
-
*
|
102
|
+
* input
|
103
103
|
|
104
|
-
Use this if you want to write
|
104
|
+
Use this if you want to write messages by reading lines of an input file in rotation. `field` is ignored.
|
105
105
|
|
106
|
-
*
|
106
|
+
* message
|
107
107
|
|
108
|
-
Use this if you want to write
|
108
|
+
Use this if you want to write only a specific message.
|
109
109
|
|
110
110
|
### Field Data Types
|
111
111
|
|
data/example/input.conf
ADDED
data/example/input.txt
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
id:0 time:2013-11-26 02:45:33 +0900 level:WARN method:GET uri:/api/v1/people reqtime:2.3955637407914354 foobar:3xwwVG3T
|
2
|
+
id:1 time:2013-11-26 02:45:33 +0900 level:INFO method:POST uri:/api/v1/people reqtime:4.954494736221596 foobar:kRP5SiBW
|
3
|
+
id:2 time:2013-11-26 02:45:33 +0900 level:DEBUG method:POST uri:/api/v1/people reqtime:1.719978260834408 foobar:0EFaal3L
|
4
|
+
id:3 time:2013-11-26 02:45:33 +0900 level:DEBUG method:POST uri:/api/v1/people reqtime:3.2873443102110755 foobar:sGMFl2xs
|
5
|
+
id:4 time:2013-11-26 02:45:33 +0900 level:INFO method:POST uri:/api/v1/textdata reqtime:1.8776513072710397 foobar:dTlmjln3
|
6
|
+
id:5 time:2013-11-26 02:45:33 +0900 level:INFO method:POST uri:/api/v1/people reqtime:2.7644992372264974 foobar:jLL6zTdt
|
7
|
+
id:6 time:2013-11-26 02:45:33 +0900 level:WARN method:POST uri:/api/v1/people reqtime:4.609761906663468 foobar:k2hegeOG
|
8
|
+
id:7 time:2013-11-26 02:45:33 +0900 level:DEBUG method:POST uri:/api/v1/people reqtime:1.7312535151311619 foobar:JpwUkYKs
|
9
|
+
id:8 time:2013-11-26 02:45:33 +0900 level:WARN method:POST uri:/api/v1/people reqtime:2.2088570489185217 foobar:eOSmfjCb
|
10
|
+
id:9 time:2013-11-26 02:45:33 +0900 level:WARN method:POST uri:/api/v1/people reqtime:2.6351789530831637 foobar:cFBI2Gsm
|
@@ -22,13 +22,16 @@ module DummyLogGenerator
|
|
22
22
|
option :worker_type, :type => :string, :default => 'process'
|
23
23
|
def start
|
24
24
|
@options = @options.dup # avoid frozen
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
dsl =
|
26
|
+
if options[:config] && File.exists?(options[:config])
|
27
|
+
instance_eval(File.read(options[:config]), options[:config])
|
28
|
+
else
|
29
|
+
DummyLogGenerator::Dsl.new
|
30
|
+
end
|
31
|
+
@options[:setting] = dsl.setting
|
32
|
+
@options[:rate] ||= dsl.setting.rate
|
33
|
+
# options for serverengine
|
34
|
+
@options[:workers] ||= dsl.setting.workers
|
32
35
|
|
33
36
|
opts = @options.symbolize_keys.except(:config)
|
34
37
|
se = ServerEngine.create(nil, DummyLogGenerator::Worker, opts)
|
@@ -2,13 +2,14 @@ module DummyLogGenerator
|
|
2
2
|
class Generator
|
3
3
|
def initialize(setting)
|
4
4
|
@message_proc =
|
5
|
-
if
|
5
|
+
if fields = setting.fields
|
6
|
+
labeled, delimiter = setting.labeled, setting.delimiter
|
7
|
+
prepare_message_proc_for_fields(fields, labeled, delimiter)
|
8
|
+
elsif input = setting.input
|
6
9
|
prepare_message_proc_for_input(input)
|
7
|
-
elsif message = setting.message
|
8
|
-
prepare_message_proc_for_message(message)
|
9
10
|
else
|
10
|
-
|
11
|
-
|
11
|
+
message = setting.message
|
12
|
+
prepare_message_proc_for_message(message)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -7,9 +7,9 @@ module DummyLogGenerator
|
|
7
7
|
@output = STDOUT
|
8
8
|
@labeled = true
|
9
9
|
@delimiter = "\t"
|
10
|
-
@fields =
|
10
|
+
@fields = nil
|
11
11
|
@workers = 1
|
12
|
-
@message =
|
12
|
+
@message = "time:2013-11-25 00:23:52 +0900\tlevel:ERROR\tmethod:POST\turi:/api/v1/people\treqtime:3.1983877060667103\n"
|
13
13
|
@input = nil
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dummy_log_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonots
|
@@ -128,8 +128,11 @@ files:
|
|
128
128
|
- bin/dummy_log_generator
|
129
129
|
- bin/dummy_log_generator_simple
|
130
130
|
- bin/dummy_log_generator_yes
|
131
|
-
- dummy_log_generator.conf
|
132
131
|
- dummy_log_generator.gemspec
|
132
|
+
- example/input.conf
|
133
|
+
- example/input.txt
|
134
|
+
- example/message.conf
|
135
|
+
- example/sample.conf
|
133
136
|
- lib/dummy_log_generator.rb
|
134
137
|
- lib/dummy_log_generator/cli.rb
|
135
138
|
- lib/dummy_log_generator/dsl.rb
|