mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-10-31 23:26:35 +08:00 
			
		
		
		
	Normal log and error log are printed in the same call.
This commit is contained in:
		
							parent
							
								
									e2242b59e6
								
							
						
					
					
						commit
						f63a354b40
					
				
							
								
								
									
										3
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								gin.go
									
									
									
									
									
								
							| @ -113,6 +113,9 @@ func (a errorMsgs) ByType(typ uint32) errorMsgs { | ||||
| } | ||||
| 
 | ||||
| func (a errorMsgs) String() string { | ||||
| 	if len(a) == 0 { | ||||
| 		return "" | ||||
| 	} | ||||
| 	var buffer bytes.Buffer | ||||
| 	for i, msg := range a { | ||||
| 		text := fmt.Sprintf("Error #%02d: %s \n     Meta: %v\n", (i + 1), msg.Err, msg.Meta) | ||||
|  | ||||
| @ -67,17 +67,13 @@ func Logger() HandlerFunc { | ||||
| 		} | ||||
| 		end := time.Now() | ||||
| 		latency := end.Sub(start) | ||||
| 		stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n", | ||||
| 		stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n%s", | ||||
| 			end.Format("2006/01/02 - 15:04:05"), | ||||
| 			color, code, reset, | ||||
| 			latency, | ||||
| 			requester, | ||||
| 			c.Request.Method, c.Request.URL.Path, | ||||
| 			c.Errors.String(), | ||||
| 		) | ||||
| 
 | ||||
| 		// Calculate resolution time | ||||
| 		if len(c.Errors) > 0 { | ||||
| 			stdlogger.Println(c.Errors.String()) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user