Example #1
0
File: logger.go Project: elago/ela
func responseLog(ctx Context) {
	content := "[%s] %s: complete %s %s %d\n"
	switch ctx.GetResponseWriter().Status() {
	case 301, 302:
		log.Bluef(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	case 304:
		log.Greenf(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	case 401, 403:
		log.Yellowf(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	case 404:
		log.Redf(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	case 500:
		log.Pinkf(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	default:
		log.Printf(content, tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetResponseWriter().Status())
	}

}
Example #2
0
File: logger.go Project: elago/ela
func requestLog(ctx Context) {
	log.Printf("[%s] %s: starting %s %s %s\n", tag, time.Now().Format(logTimeFormat), ctx.GetRequest().Method, ctx.GetRequest().RequestURI, ctx.GetRequest().RemoteAddr)
}