-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-small.py
112 lines (93 loc) · 4.35 KB
/
config-small.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
####
###
##
# Don't delete stuff unless you want an error...
##
###
####
from extra import Configuration, Statistics
###
# Gentlemen, set your window width to 120 characters. You have been warned.
###
#----------------------------------------------------------------------------------------------------------------------
# config
#----------------------------------------------------------------------------------------------------------------------
LOG_LINE_BYTES = 377
A_GOOD_CHUNK_TO_READ = 4096 * 10 # bytes
CLOSE_ENOUGH = 8128 # bytes
config = Configuration(
# Path to log to default to if none is specified on the command line.
DEFAULT_LOG = "loggen.log",
# used to calculate a second's worth of bytes
BYTES_PER_SECOND_FUDGE_FACTOR = 1.2,
# Must be more than the max log line by the length of the timestamp. Used in initial binary time-adjusted search for
# reading chunks of the file. Must be more than one line so it can find a newline and find the timestamp after it.
MORE_THAN_ONE_LINE = LOG_LINE_BYTES * 3, # bytes
# The size of the timestamp in bytes. "Feb 13 18:31:36" is 15 bytes for ASCII. Bump this up if you're modifying
# this to work with unicode. You're allowed to go over without penalty (except file read time); don't go under.
LOG_TIMESTAMP_SIZE = 20, # bytes
LOG_TIMESTAMP_PARTS = 3, # "Feb", "13", "18:31:36"
# If the time-adjusted binary search hits inside the region of desired logs, it's not much help. We need mins and
# maxes. This is how much to move the out by (out from the focus towards lower or upper bound). Closer to 0 makes the
# search faster & more aggressive, but too close makes wide sweep's time-adjusted binary search fail too fast and
# leaves too much of the log for edge sweep to chug through linearly.
REFOCUS_FACTOR = 0.15, # 15%
# The initial binary time-adjusted search will quit once it's either this close (in bytes) or stabalized.
WIDE_SWEEP_CLOSE_ENOUGH = CLOSE_ENOUGH, # bytes.
# Amount (in bytes) of the file that the edge-finding algorithm will read in at a time. Higher /might/ give better
# speed but will also use more memory.
EDGE_SWEEP_CHUNK_SIZE = A_GOOD_CHUNK_TO_READ, # bytes
# Amount (in bytes) of the file that will be read and printed at a time. Higher should give better speed but
# will use more meory.
MAX_PRINT_CHUNK_SIZE = A_GOOD_CHUNK_TO_READ, # bytes
# This is the regex for the acceptable input format for times. Don't fuck it up.
# Good:
# 1:2:3
# 22:33
# 23:33:11
# 23:33-23:33:1
# 23:33:1-23:33
# 23:33:1-23:33:1
# 23:33:11-23:33:11
#
# Bad:
# 23:33:-23:33
# 23:33-23:33:
# 23:33:-23:33:
# 22:33:44:1
TIME_REGEX = r'^((?:\d{1,2}:){1,2}\d{1,2})(?:-((?:\d{1,2}:){1,2}\d{1,2}))?$',
# Sometimes two different sections of a log will match a supplied time range. For example, the log file goes from Feb
# 12 06:30 to Feb 13 07:00, and the user asks for logs with timestamp 6:50. That's in both the Feb 12 and Feb 13 parts
# of the file. How do you want these seperated when they're printed out?
DOUBLE_MATCH_SEP = '\n\n\n', # use '' for no seperator; don't forget the \n if you want one
# Don't turn this on. Seriously... Unless you want to debug and all the debug prints are on your branch.
DEBUG = False,
# May break tgrep. May make it go faster... May do nothing at all.
EXPERIMENTAL = False # Currently switches to binary search when time search can't do any better. Usually helps.
)
#----------------------------------------------------------------------------------------------------------------------
# stats: This is what you get when you use -v
#----------------------------------------------------------------------------------------------------------------------
stats = Statistics(
# Here FYI. I guess you can change if you want to throw off your statistics...
# Set seeks and reads to -20 and see how awesome I do!
# regular verbosity statistics
seeks = 0,
reads = 0, # total
print_reads = 0, # print-only
wide_sweep_loops = 0, # total
edge_sweep_loops = 0,
wide_sweep_time = None,
edge_sweep_time = None,
find_time = None,
print_time = None,
print_size = 0, # bytes
file_size = '0 bytes',
# extra verbosity statistics
edge_sweep_size = 0, # bytes
refocused_wide_sweep_loops = 0,
binary_wide_sweep_loops = 0,
requested_times = [],
wide_sweep_end_locs = [],
final_locs = []
)