-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_generator.py
66 lines (59 loc) · 1.8 KB
/
log_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Compatibility layer for Random Log Generator.
This module provides backward compatibility with the original log_generator.py script.
It imports and re-exports the necessary functions and classes from the new package structure.
"""
import logging
import sys
import warnings
# Show deprecation warning
warnings.warn(
"Direct use of log_generator.py is deprecated. "
"Please use the random_log_generator package instead.",
DeprecationWarning,
stacklevel=2
)
# Import from the new package structure
from random_log_generator.core.generator import (
generate_log_line,
write_logs,
main
)
from random_log_generator.core.strategies import (
write_logs_random_rate,
write_logs_random_segments
)
from random_log_generator.core.rate_limiter import TokenBucket
from random_log_generator.metrics.collector import Metrics
from random_log_generator.utils.ip_generator import generate_ip_address
from random_log_generator.utils.user_agents import (
generate_random_user_agent,
generate_random_user_agent_uncached
)
from random_log_generator.output.rotation import rotate_log_file
from random_log_generator.config.config_loader import load_config
# Re-export all the imported names
__all__ = [
'generate_log_line',
'write_logs',
'write_logs_random_rate',
'write_logs_random_segments',
'TokenBucket',
'Metrics',
'generate_ip_address',
'generate_random_user_agent',
'generate_random_user_agent_uncached',
'rotate_log_file',
'main'
]
# Load configuration
try:
config_data = load_config('config.yaml')
CONFIG = config_data
except Exception as e:
logging.error(f"Error loading configuration: {e}")
sys.exit(1)
if __name__ == "__main__":
# Run the main function with the loaded configuration
sys.exit(main(CONFIG))