Skip to content

Commit 9465ace

Browse files
Holy Logs Fix coz i cooked the merge conflict my bad
1 parent b88fdd8 commit 9465ace

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

pkg/controllers/logs.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ package controllers
33
import (
44
"encoding/json"
55
"net/http"
6-
"time"
76

87
"github.com/CodeChefVIT/devsoc-backend-26/pkg/db"
8+
"github.com/CodeChefVIT/devsoc-backend-26/pkg/dto"
99
"github.com/CodeChefVIT/devsoc-backend-26/pkg/elastic"
1010
"github.com/CodeChefVIT/devsoc-backend-26/pkg/models"
11-
"github.com/CodeChefVIT/devsoc-backend-26/pkg/dto"
1211
"github.com/labstack/echo/v4"
1312
)
1413

@@ -35,17 +34,12 @@ func GetLogs(c echo.Context) error {
3534
createdBy = &s
3635
}
3736

38-
createdAt := ""
39-
if l.CreatedAt.Valid {
40-
createdAt = l.CreatedAt.Time.Format(time.RFC3339)
41-
}
42-
4337
resp = append(resp, dto.Log{
4438
ID: l.ID.String(),
4539
Type: l.Type,
4640
Body: body,
4741
CreatedBy: createdBy,
48-
CreatedAt: createdAt,
42+
CreatedAt: l.CreatedAt.Time,
4943
})
5044
}
5145

pkg/dto/logs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import "time"
55
type Log struct {
66
ID string `json:"id"`
77
Type string `json:"type"`
8+
Method string `json:"method"`
9+
URL string `json:"url"`
10+
IPAddress string `json:"ip_address"`
11+
UserAgent string `json:"user_agent"`
812
Body interface{} `json:"body"`
913
CreatedBy *string `json:"created_by"`
1014
CreatedAt time.Time `json:"created_at"`

pkg/middlewares/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func RequestLogger(next echo.HandlerFunc) echo.HandlerFunc {
6262
}
6363

6464
if log.CreatedBy.Valid {
65-
idstr := log.CreatedBy.String()
65+
idstr := log.CreatedBy.String
6666
esLog.CreatedBy = &idstr
6767
}
6868

0 commit comments

Comments
 (0)