Skip to content

Commit

Permalink
Add Logging for Request Variables Using xgo (#2328)
Browse files Browse the repository at this point in the history
* Add logging for request variables using xgo

* using printf instead of machine since it was halting

* got the variables from each function

---------

Co-authored-by: kevkevinpal <[email protected]>
  • Loading branch information
saithsab877 and kevkevinpal authored Jan 22, 2025
1 parent 5a521c0 commit a2820e5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions routes/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,24 @@ func internalServerErrorHandler(next http.Handler) http.Handler {
if index != -1 {
trimmed = f.File[index:]
}
//fmt.Printf("%s:%d %s\n", trimmed, f.Line, f.Name)

newContent := fmt.Sprintf("%s:%d %s,\n", trimmed, f.Line, f.Name)
if elements_chain.Len()+len(newContent) <= 512000 {
maxByteSize := 177000
if elements_chain.Len()+len(newContent) <= maxByteSize && isExceedingLimit == false {
elements_chain.WriteString(newContent)
if args != nil && args.NumField() != 0 {
for i := 0; i < args.NumField(); i++ {
thingWeWantToPrint := args.GetFieldIndex(i)
argNameAndValue := fmt.Sprintf("Name: %s Value: %#v\n", thingWeWantToPrint.Name(), thingWeWantToPrint.Value())
if elements_chain.Len()+len(argNameAndValue) <= maxByteSize {
elements_chain.WriteString(argNameAndValue)
} else {
fmt.Printf("elements_chain length exceeded 500KB, skipping further additions.\n")
isExceedingLimit = true
}
}
}
} else if isExceedingLimit == false {
// Optionally, you could log or handle this case differently if needed
fmt.Printf("elements_chain length exceeded 500KB, skipping further additions.\n")
isExceedingLimit = true
}
Expand Down

0 comments on commit a2820e5

Please sign in to comment.