INNER CODE UNIT · Python
parse_status_type
lebinh/ngxtop · ngxtop/ngxtop.py:289
def parse_status_type(record):
return record['status'] // 100 if 'status' in record else None
def to_int(value):
return int(value) if value and value != '-' else 0
def to_float(value):
return float(value) if value and value != '-' else 0.0
def parse_caddy_log(lines):
"""Parse Caddy JSON log format and convert to ngxtop's expected format."""
for line in lines:
try:
# Extract the JSON part of the line
# Caddy logs have format: timestamp INFO http.log.access.log2 handled request {json}