|
|
@ -23,6 +23,7 @@ var (
|
|
|
|
ftruncate bool // whether or not to truncate file on open
|
|
|
|
ftruncate bool // whether or not to truncate file on open
|
|
|
|
pidfile string // path of pidfile to write out
|
|
|
|
pidfile string // path of pidfile to write out
|
|
|
|
reopen bool // whether or not to reopen the file handle on every line write
|
|
|
|
reopen bool // whether or not to reopen the file handle on every line write
|
|
|
|
|
|
|
|
nots float64 // odds of generating a line without a timestamp. Should be between 0 and 1.
|
|
|
|
tsformat string // timestamp format
|
|
|
|
tsformat string // timestamp format
|
|
|
|
lineLength lengthArg // length of the lines to be generated
|
|
|
|
lineLength lengthArg // length of the lines to be generated
|
|
|
|
ts func() string // function to get a timestamp string
|
|
|
|
ts func() string // function to get a timestamp string
|
|
|
@ -298,7 +299,23 @@ func flags() (err error) {
|
|
|
|
if dictionary != "" {
|
|
|
|
if dictionary != "" {
|
|
|
|
readDict(dictionary)
|
|
|
|
readDict(dictionary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ts = mkTsFn()
|
|
|
|
tmp := mkTsFn()
|
|
|
|
|
|
|
|
tsLen := len(tmp())
|
|
|
|
|
|
|
|
blank := make([]byte, tsLen)
|
|
|
|
|
|
|
|
for i := range blank {
|
|
|
|
|
|
|
|
blank[i] = ' '
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
whitespace := string(blank)
|
|
|
|
|
|
|
|
if nots > 0 {
|
|
|
|
|
|
|
|
ts = func() string {
|
|
|
|
|
|
|
|
if rand.Float64() < nots {
|
|
|
|
|
|
|
|
return whitespace
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ts = tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
line, err = lineLength.mkLineFn()
|
|
|
|
line, err = lineLength.mkLineFn()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -321,6 +338,7 @@ func main() {
|
|
|
|
func init() {
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&fname, "file", "", "destination file to which random data will be written")
|
|
|
|
flag.StringVar(&fname, "file", "", "destination file to which random data will be written")
|
|
|
|
flag.StringVar(&tsformat, "ts-format", "", "timestamp format")
|
|
|
|
flag.StringVar(&tsformat, "ts-format", "", "timestamp format")
|
|
|
|
|
|
|
|
flag.Float64Var(¬s, "no-ts", 0.0, "odds of generating a line without a timestamp")
|
|
|
|
flag.StringVar(&pidfile, "pidfile", "", "file to which a pid is written")
|
|
|
|
flag.StringVar(&pidfile, "pidfile", "", "file to which a pid is written")
|
|
|
|
flag.BoolVar(&ftruncate, "truncate", false, "truncate file on opening instead of appending")
|
|
|
|
flag.BoolVar(&ftruncate, "truncate", false, "truncate file on opening instead of appending")
|
|
|
|
flag.StringVar(&dictionary, "dict", "", "dictionary of words to use for generating log data")
|
|
|
|
flag.StringVar(&dictionary, "dict", "", "dictionary of words to use for generating log data")
|
|
|
|