mirror of
https://github.com/Febbweiss/Fake-Apache-Log-Generator.git
synced 2026-03-04 22:35:35 +00:00
Add --sleep option to sleep between line generation
This commit is contained in:
@@ -40,6 +40,7 @@ parser = argparse.ArgumentParser(__file__, description="Fake Apache Log Generato
|
|||||||
parser.add_argument("--output", "-o", dest='output_type', help="Write to a Log file, a gzip file or to STDOUT", choices=['LOG','GZ','CONSOLE'] )
|
parser.add_argument("--output", "-o", dest='output_type', help="Write to a Log file, a gzip file or to STDOUT", choices=['LOG','GZ','CONSOLE'] )
|
||||||
parser.add_argument("--num", "-n", dest='num_lines', help="Number of lines to generate (0 for infinite)", type=int, default=1)
|
parser.add_argument("--num", "-n", dest='num_lines', help="Number of lines to generate (0 for infinite)", type=int, default=1)
|
||||||
parser.add_argument("--prefix", "-p", dest='file_prefix', help="Prefix the output file name", type=str)
|
parser.add_argument("--prefix", "-p", dest='file_prefix', help="Prefix the output file name", type=str)
|
||||||
|
parser.add_argument("--sleep", "-s", help="Sleep this long between lines", default=0.0, type=float)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -75,6 +76,9 @@ ualist = [faker.firefox, faker.chrome, faker.safari, faker.internet_explorer, fa
|
|||||||
|
|
||||||
flag = True
|
flag = True
|
||||||
while (flag):
|
while (flag):
|
||||||
|
if args.sleep:
|
||||||
|
increment = datetime.timedelta(seconds=args.sleep)
|
||||||
|
else:
|
||||||
increment = datetime.timedelta(seconds=random.randint(30, 300))
|
increment = datetime.timedelta(seconds=random.randint(30, 300))
|
||||||
otime += increment
|
otime += increment
|
||||||
|
|
||||||
@@ -95,3 +99,5 @@ while (flag):
|
|||||||
|
|
||||||
log_lines = log_lines - 1
|
log_lines = log_lines - 1
|
||||||
flag = False if log_lines == 0 else True
|
flag = False if log_lines == 0 else True
|
||||||
|
if args.sleep:
|
||||||
|
time.sleep(args.sleep)
|
||||||
|
|||||||
Reference in New Issue
Block a user