@@ -48,9 +48,9 @@ func main() {
4848 gocolorlog.Error (" Failed to connect to DB" )
4949 gocolorlog.Errorf (" Failed to open file: %s " , " config.yaml" )
5050
51- gocolorlog.HTTP (200 , " GET" , " /api/test" , 120 *time.Millisecond , nil )
52- gocolorlog.HTTP (404 , " POST" , " /api/notfound" , 80 *time.Millisecond , nil )
53- gocolorlog.HTTP (500 , " DELETE" , " /api/error" , 200 *time.Millisecond , fmt.Errorf (" internal server error" ))
51+ gocolorlog.HTTP (200 , " GET" , " /api/test" , 120 *time.Millisecond ," ip-adress " , nil )
52+ gocolorlog.HTTP (404 , " POST" , " /api/notfound" , 80 *time.Millisecond ," ip-adress " , nil )
53+ gocolorlog.HTTP (500 , " DELETE" , " /api/error" , 200 *time.Millisecond ," ip-adress " , fmt.Errorf (" internal server error" ))
5454
5555 gocolorlog.ContextLevel (" INFO" , " Bootstrap" , " Application is running on: %s " , " http://localhost:3000" )
5656}
@@ -64,9 +64,9 @@ func main() {
6464[Log] 12345 - 2025-05-15 12:34:56 [WARN ] [App] Slow query: SELECT * FROM users
6565[Log] 12345 - 2025-05-15 12:34:56 [ERROR] [App] Failed to connect to DB
6666[Log] 12345 - 2025-05-15 12:34:56 [ERROR] [App] Failed to open file: config.yaml
67- [Log] 12345 - 2025-05-15 12:34:56 [ HTTP ] [200] GET /api/test 200 120ms - 120ms
68- [Log] 12345 - 2025-05-15 12:34:56 [ HTTP ] [404] POST /api/notfound 404 80ms - 80ms
69- [Log] 12345 - 2025-05-15 12:34:56 [ HTTP ] [500] DELETE /api/error 500 200ms - 200ms handler error : internal server error
67+ [Log] 62388 - 2025-05-16 21:29:01 HTTP [200] GET | /api/test | 200 | 120ms - 120ms | 192.168.1.1
68+ [Log] 62388 - 2025-05-16 21:29:01 HTTP [404] POST | /api/notfound | 404 | 80ms - 80ms | 192.168.1.1 |
69+ [Log] 62388 - 2025-05-16 21:29:01 HTTP [500] DELETE | /api/error | 500 | 200ms - 200ms | 192.168.1.1 | [Error] : internal server error
7070[Log] 12345 - 2025-05-15 12:34:56 [INFO ] [Bootstrap] Application is running on: http://localhost:3000
7171```
7272* (Colors will be visible in a terminal that supports ANSI colors.)*
@@ -85,7 +85,7 @@ type Logger interface {
8585 Warnf (format string , args ...any )
8686 Error (msg string )
8787 Errorf (format string , args ...any )
88- HTTP (status int , method, path string , latency time.Duration , err error )
88+ HTTP (status int , method, path string , latency time.Duration , ip string , err error )
8989 ContextLevel (level, context, msg string , args ...any )
9090}
9191```
@@ -105,7 +105,7 @@ type Logger interface {
105105``` go
106106gocolorlog.Info (" Message" )
107107gocolorlog.Warnf (" Warning: %s " , " details" )
108- gocolorlog.HTTP (404 , " POST" , " /api/notfound" , 80 *time.Millisecond , nil )
108+ gocolorlog.HTTP (404 , " POST" , " /api/notfound" , 80 *time.Millisecond ," ip-adress " nil )
109109gocolorlog.ContextLevel (" ERROR" , " DB" , " Connection error: %v " , err)
110110```
111111
0 commit comments