dummy_log_generator 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edaffe0f73cbc9aafc71dc10db3eeb80bfed02d6
4
- data.tar.gz: 807e80562f29882db31edee29b8dac692e098caa
3
+ metadata.gz: 760e8bbf26f9bfcc32494aed36086f062ee5fe28
4
+ data.tar.gz: 64cfb639cc486f51dcf403020b5085c5dc9216ee
5
5
  SHA512:
6
- metadata.gz: a229cbbf0c5863bd2d5a17417d3074d73f6f71c58f53a763a81959f4dd79f4b6e356454ccc7414a2094c90974e950f6ad18203ad6d68174cc51f7e9dfe6c1a4b
7
- data.tar.gz: 7b220a87b3e6296d436198e16be03ce7fd2a2a3b391f0f8a925e474c3fb04d007006da2ee627a982751ff43956bfbc7923c5bf4f3e1f9c402133fc3239af14b9
6
+ metadata.gz: 0958e911b83801d2b133b2d25689e930f3dc3c0771ba87f7fca57e45a25599fa6bed97d5f8aad6ee448e5cd4a4dbb3dcd0f766717c77a0cbd7cd6b7cae5bf8c3
7
+ data.tar.gz: 6ca6c0a19b9740d2b8063094427eb6acc723d5b41bc84957bcdce6c2d83d9b6246f65e58ecc37b58babc5f0d3fc292d5c4920020215645bbb510f0f50fd01395
@@ -1,3 +1,9 @@
1
+ ### 0.2.1
2
+
3
+ Change:
4
+
5
+ * Change the default behavior to use the default `message` rather than `field`.
6
+
1
7
  ### 0.2.0
2
8
 
3
9
  Enhancement:
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: true
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:422 time:[2013-11-19 02:34:58] level:INFO method:POST uri:/api/v1/textdata reqtime:3.9726677258569842 foobar:LFK6XV1N
70
- id:423 time:[2013-11-19 02:34:58] level:DEBUG method:GET uri:/api/v1/people reqtime:0.49912949125272277 foobar:DcOYrONH
71
- id:424 time:[2013-11-19 02:34:58] level:WARN method:POST uri:/api/v1/textdata reqtime:2.930590441869852 foobar:XEZ5bQsh
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
- * message
102
+ * input
103
103
 
104
- Use this if you want to write only a specific message. `field` is ignored.
104
+ Use this if you want to write messages by reading lines of an input file in rotation. `field` is ignored.
105
105
 
106
- * input
106
+ * message
107
107
 
108
- Use this if you want to write messages by reading lines of an input file in rotation. `field` and `message` are ignored.
108
+ Use this if you want to write only a specific message.
109
109
 
110
110
  ### Field Data Types
111
111
 
@@ -0,0 +1,6 @@
1
+ configure 'input' do
2
+ output "dummy_log_generator.log"
3
+ rate 500
4
+ input "example/input.txt"
5
+ end
6
+
@@ -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
@@ -0,0 +1,5 @@
1
+ configure 'message' do
2
+ output "dummy_log_generator.log"
3
+ rate 500
4
+ message "time:2013-11-25 00:23:52 +0900\tlevel:ERROR\tmethod:POST\turi:/api/v1/people\treqtime:3.1983877060667103\n"
5
+ end
@@ -1,5 +1,5 @@
1
1
  configure 'sample' do
2
- # output "dummy_log_generator.log"
2
+ output "dummy_log_generator.log"
3
3
  rate 500
4
4
  delimiter "\t"
5
5
  labeled true
@@ -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
- if options[:config] && File.exists?(options[:config])
26
- dsl = instance_eval(File.read(options[:config]), options[:config])
27
- @options[:setting] = dsl.setting
28
- @options[:rate] ||= dsl.setting.rate
29
- # options for serverengine
30
- @options[:workers] ||= dsl.setting.workers
31
- end
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)
@@ -15,6 +15,7 @@ module DummyLogGenerator
15
15
  end
16
16
 
17
17
  def field(name, opts)
18
+ setting.fields ||= {}
18
19
  setting.fields[name] = opts
19
20
  end
20
21
  end
@@ -2,13 +2,14 @@ module DummyLogGenerator
2
2
  class Generator
3
3
  def initialize(setting)
4
4
  @message_proc =
5
- if input = setting.input
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
- fields, labeled, delimiter = setting.fields, setting.labeled, setting.delimiter
11
- prepare_message_proc_for_fields(fields, labeled, delimiter)
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 = nil
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
@@ -1,3 +1,3 @@
1
1
  module DummyLogGenerator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  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.0
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