Refactor check_logs function in checker.py to simplify log handling. Removed subscription message detection logic and replaced it with a basic line printing mechanism. The function now returns a default status of "Idle", streamlining the process and reducing complexity in log analysis.
This commit is contained in:
		
							
								
								
									
										23
									
								
								checker.py
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								checker.py
									
									
									
									
									
								
							@ -138,24 +138,11 @@ def check_logs(log_handler):
 | 
			
		||||
    except subprocess.CalledProcessError as e:
 | 
			
		||||
        raise RuntimeError(f"Error running docker logs: {e}")
 | 
			
		||||
    
 | 
			
		||||
    subscription_pattern = r'\[info\s*\].*Ignored subscription creation.*id=(\d+).*err=(.+?)(?=\s+\[|$)'
 | 
			
		||||
    matches = list(re.finditer(subscription_pattern, log_content))
 | 
			
		||||
    
 | 
			
		||||
    if not matches:
 | 
			
		||||
        log_handler.info("No subscription messages found")
 | 
			
		||||
        return {"status": "Idle"}
 | 
			
		||||
    
 | 
			
		||||
    last_match = matches[-1]
 | 
			
		||||
    last_id = last_match.group(1)
 | 
			
		||||
    error_type = last_match.group(2).strip()
 | 
			
		||||
    
 | 
			
		||||
    if error_type == "Container-set not supported":
 | 
			
		||||
        status = f"Container error (id: {last_id})"
 | 
			
		||||
    else:
 | 
			
		||||
        status = f"Subscription {last_id}"
 | 
			
		||||
    
 | 
			
		||||
    log_handler.info(f"Found subscription message: id={last_id}, error={error_type}")
 | 
			
		||||
    return {"status": status}
 | 
			
		||||
    for line in log_content.splitlines():
 | 
			
		||||
        print(line)
 | 
			
		||||
 | 
			
		||||
    return {"status": "Idle"}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    colorama.init(autoreset=True)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user