dummy_log_generator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +25 -9
- data/dummy_log_generator.conf +1 -1
- data/lib/dummy_log_generator/formatter.rb +1 -2
- data/lib/dummy_log_generator/generator.rb +16 -8
- data/lib/dummy_log_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87393b7e11cfd15b9095bd7017a3cc9114862326
|
4
|
+
data.tar.gz: bebf7667d4944db0f8f780108f766a387e963b0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d90ec26f92a62473ccc1dd36429ef5f725e5f62448bb80fca062ea981a691fc97a4c72eab4f747632108cd3776e591f922d87240713edc1c719b3ff2047df270
|
7
|
+
data.tar.gz: 76d4e265b8c44a7cea642c5aa0f469be9aa841a1369c6454fb2059491903b1ba75712b5031ced0939834fe9dc7e674f9c4df1d422f72b39cb3e7b0d92ecf4d6c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Sample configuration is as follows:
|
|
29
29
|
configure 'sample' do
|
30
30
|
rate 500
|
31
31
|
delimiter "\t"
|
32
|
-
labeled
|
32
|
+
labeled true
|
33
33
|
field :id, type: :integer, countup: true
|
34
34
|
field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: true
|
35
35
|
field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
|
@@ -43,9 +43,9 @@ end
|
|
43
43
|
Running dummy_log_generator outputs like
|
44
44
|
|
45
45
|
```
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
id:422 time:[2013-11-19 02:34:58] level:INFO method:POST uri:/api/v1/textdata reqtime:3.9726677258569842 foobar:LFK6XV1N
|
47
|
+
id:423 time:[2013-11-19 02:34:58] level:DEBUG method:GET uri:/api/v1/people reqtime:0.49912949125272277 foobar:DcOYrONH
|
48
|
+
id:424 time:[2013-11-19 02:34:58] level:WARN method:POST uri:/api/v1/textdata reqtime:2.930590441869852 foobar:XEZ5bQsh
|
49
49
|
```
|
50
50
|
|
51
51
|
## Configuration Parameters
|
@@ -58,17 +58,17 @@ Following parameters for configuration is available
|
|
58
58
|
|
59
59
|
* delimiter
|
60
60
|
|
61
|
-
Specify the delimiter between each
|
61
|
+
Specify the delimiter between each field. Default: "\t" (Tab)
|
62
62
|
|
63
63
|
* labeled
|
64
64
|
|
65
|
-
|
65
|
+
Whether add field name as a label or not. Default: true
|
66
66
|
|
67
67
|
* field
|
68
68
|
|
69
69
|
Define data fields to generate
|
70
70
|
|
71
|
-
## Data Types
|
71
|
+
## Field Data Types
|
72
72
|
|
73
73
|
You can specify following data types to your `field` parameters:
|
74
74
|
|
@@ -80,7 +80,11 @@ You can specify following data types to your `field` parameters:
|
|
80
80
|
|
81
81
|
* :random
|
82
82
|
|
83
|
-
Generate datetime randomly
|
83
|
+
Generate datetime randomly. Default: false (Time.now)
|
84
|
+
|
85
|
+
* :value
|
86
|
+
|
87
|
+
You can specify a fixed Time object.
|
84
88
|
|
85
89
|
* :string
|
86
90
|
|
@@ -92,6 +96,10 @@ You can specify following data types to your `field` parameters:
|
|
92
96
|
|
93
97
|
You can specify the length of string to generate randomly
|
94
98
|
|
99
|
+
* :value
|
100
|
+
|
101
|
+
You can specify a fixed string
|
102
|
+
|
95
103
|
* :integer
|
96
104
|
|
97
105
|
* :range
|
@@ -102,11 +110,19 @@ You can specify following data types to your `field` parameters:
|
|
102
110
|
|
103
111
|
Generate countup data. Default: false
|
104
112
|
|
113
|
+
* :value
|
114
|
+
|
115
|
+
You can specify a fixed integer
|
116
|
+
|
105
117
|
* :float
|
106
118
|
|
107
119
|
* :range
|
108
120
|
|
109
|
-
You can specify a range of
|
121
|
+
You can specify a range of float numbers, then the generator picks one in the range (uniform) randomly
|
122
|
+
|
123
|
+
* :value
|
124
|
+
|
125
|
+
You can specify a fixed float number
|
110
126
|
|
111
127
|
## Relatives
|
112
128
|
|
data/dummy_log_generator.conf
CHANGED
@@ -38,16 +38,20 @@ module DummyLogGenerator
|
|
38
38
|
@chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a # no symbols and multi-bytes for now
|
39
39
|
end
|
40
40
|
|
41
|
-
def string(length: 8, any: nil, prev: nil)
|
42
|
-
if
|
41
|
+
def string(length: 8, any: nil, prev: nil, value: nil)
|
42
|
+
if value
|
43
|
+
value.to_s
|
44
|
+
elsif any
|
43
45
|
self.any(any)
|
44
46
|
else
|
45
47
|
Array.new(length){@chars[rand(@chars.size-1)]}.join
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
def integer(range: nil, countup: false, prev: nil)
|
50
|
-
if
|
51
|
+
def integer(range: nil, countup: false, prev: nil, value: nil)
|
52
|
+
if value
|
53
|
+
value.to_i
|
54
|
+
elsif range
|
51
55
|
self.range(range)
|
52
56
|
elsif countup
|
53
57
|
prev ||= -1
|
@@ -57,8 +61,10 @@ module DummyLogGenerator
|
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
60
|
-
def float(range: nil, prev: nil)
|
61
|
-
if
|
64
|
+
def float(range: nil, prev: nil, value: nil)
|
65
|
+
if value
|
66
|
+
value.to_f
|
67
|
+
elsif range
|
62
68
|
self.range(range)
|
63
69
|
else
|
64
70
|
r = rand(1..358)
|
@@ -66,8 +72,10 @@ module DummyLogGenerator
|
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
69
|
-
def datetime(format: "%Y-%m-%d %H:%M:%S.%3N", random: false, prev: nil)
|
70
|
-
time = if
|
75
|
+
def datetime(format: "%Y-%m-%d %H:%M:%S.%3N", random: false, prev: nil, value: nil)
|
76
|
+
time = if value
|
77
|
+
value
|
78
|
+
elsif random
|
71
79
|
y = rand(1970..2037);
|
72
80
|
m = rand(1..12);
|
73
81
|
d = rand(1..27);
|