MCPcopy Index your code
hub / github.com/StackStorm/st2 / _post_process

Function _post_process

tools/log_watcher.py:127–170  ·  view source on GitHub ↗
(file_dir)

Source from the content-addressed store, hash-verified

125
126
127def _post_process(file_dir):
128 alerts = []
129 for fil, lines in six.iteritems(FILE_LINE_COUNT):
130 log_lines_count_level = FILE_LOG_COUNT[fil]
131 total_log_count = 0
132 for level, count in six.iteritems(log_lines_count_level):
133 total_log_count += count
134 if total_log_count > 0:
135 if float(total_log_count) / lines * 100 > LOG_ALERT_PERCENT:
136 if file_dir in fil:
137 fil = fil[len(file_dir) + 1 :]
138 alerts.append(
139 [
140 fil,
141 lines,
142 total_log_count,
143 float(total_log_count) / lines * 100,
144 log_lines_count_level["audit"],
145 log_lines_count_level["exception"],
146 log_lines_count_level["error"],
147 log_lines_count_level["warning"],
148 log_lines_count_level["info"],
149 log_lines_count_level["debug"],
150 ]
151 )
152 # sort by percent
153 alerts.sort(key=lambda alert: alert[3], reverse=True)
154 print(
155 tabulate(
156 alerts,
157 headers=[
158 "File",
159 "Lines",
160 "Logs",
161 "Percent",
162 "adt",
163 "exc",
164 "err",
165 "wrn",
166 "inf",
167 "dbg",
168 ],
169 )
170 )
171
172
173def main(args):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected