mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-11-04 17:22:12 +08:00 
			
		
		
		
	not display color when set disableColor (#1072)
This commit is contained in:
		
							parent
							
								
									3856206bd0
								
							
						
					
					
						commit
						f4c9ac17a4
					
				@ -91,10 +91,11 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
 | 
				
			|||||||
			clientIP := c.ClientIP()
 | 
								clientIP := c.ClientIP()
 | 
				
			||||||
			method := c.Request.Method
 | 
								method := c.Request.Method
 | 
				
			||||||
			statusCode := c.Writer.Status()
 | 
								statusCode := c.Writer.Status()
 | 
				
			||||||
			var statusColor, methodColor string
 | 
								var statusColor, methodColor, resetColor string
 | 
				
			||||||
			if isTerm {
 | 
								if isTerm {
 | 
				
			||||||
				statusColor = colorForStatus(statusCode)
 | 
									statusColor = colorForStatus(statusCode)
 | 
				
			||||||
				methodColor = colorForMethod(method)
 | 
									methodColor = colorForMethod(method)
 | 
				
			||||||
 | 
									resetColor = reset
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			comment := c.Errors.ByType(ErrorTypePrivate).String()
 | 
								comment := c.Errors.ByType(ErrorTypePrivate).String()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -104,10 +105,10 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
 | 
								fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
 | 
				
			||||||
				end.Format("2006/01/02 - 15:04:05"),
 | 
									end.Format("2006/01/02 - 15:04:05"),
 | 
				
			||||||
				statusColor, statusCode, reset,
 | 
									statusColor, statusCode, resetColor,
 | 
				
			||||||
				latency,
 | 
									latency,
 | 
				
			||||||
				clientIP,
 | 
									clientIP,
 | 
				
			||||||
				methodColor, method, reset,
 | 
									methodColor, method, resetColor,
 | 
				
			||||||
				path,
 | 
									path,
 | 
				
			||||||
				comment,
 | 
									comment,
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user