mirror of https://github.com/knative/pkg.git
				
				
				
			Log if the deserialized line is semi-normal. (#1939)
Right now they panic and we lose all the context.
This commit is contained in:
		
							parent
							
								
									b89ac2a632
								
							
						
					
					
						commit
						c9bac6be76
					
				| 
						 | 
				
			
			@ -205,20 +205,27 @@ func (s *namespaceSource) handleLine(l []byte, pod string) {
 | 
			
		|||
		if site == "" {
 | 
			
		||||
			site = line.Caller
 | 
			
		||||
		}
 | 
			
		||||
		// E 15:04:05.000 webhook-699b7b668d-9smk2 [route-controller] [default/testroute-xyz] this is my message
 | 
			
		||||
		msg := fmt.Sprintf("%s %s %s [%s] [%s] %s",
 | 
			
		||||
			strings.ToUpper(string(line.Level[0])),
 | 
			
		||||
			line.Timestamp.Format(timeFormat),
 | 
			
		||||
			pod,
 | 
			
		||||
			site,
 | 
			
		||||
			line.Key,
 | 
			
		||||
			line.Message)
 | 
			
		||||
		func() {
 | 
			
		||||
			defer func() {
 | 
			
		||||
				if err := recover(); err != nil {
 | 
			
		||||
					logf("Invalid log format for pod %s: %s", pod, string(l))
 | 
			
		||||
				}
 | 
			
		||||
			}()
 | 
			
		||||
			// E 15:04:05.000 webhook-699b7b668d-9smk2 [route-controller] [default/testroute-xyz] this is my message
 | 
			
		||||
			msg := fmt.Sprintf("%s %s %s [%s] [%s] %s",
 | 
			
		||||
				strings.ToUpper(string(line.Level[0])),
 | 
			
		||||
				line.Timestamp.Format(timeFormat),
 | 
			
		||||
				pod,
 | 
			
		||||
				site,
 | 
			
		||||
				line.Key,
 | 
			
		||||
				line.Message)
 | 
			
		||||
 | 
			
		||||
		if line.Error != "" {
 | 
			
		||||
			msg += " err=" + line.Error
 | 
			
		||||
		}
 | 
			
		||||
			if line.Error != "" {
 | 
			
		||||
				msg += " err=" + line.Error
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		logf(msg)
 | 
			
		||||
			logf(msg)
 | 
			
		||||
		}()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue