Files
akvorado/common/kafka
Vincent Bernat a3507a3ff2 commong: move logging functions into */logs.go
The idea is that we should be able to skip it to find the true call
site. However, in some case, there is no true call site as we are in an
internal goroutine (like for Kafka). We can't do too complex things as
it would cost more CPU.

Here is the tentative. We should keep the last valid caller.

```go
// Run adds more context to an event, including "module" and "caller".
func (h contextHook) Run(e *zerolog.Event, _ zerolog.Level, _ string) {
	callStack := stack.Callers()
	callStack = callStack[3:] // Trial and error, there is a test to check it works.

	// We want to get the next caller that is in our own module but that is not logs.go.
	for _, call := range callStack {
		module := call.FunctionName()
		if !strings.HasPrefix(module, stack.ModuleName) || strings.HasSuffix(call.FileName(), "/logs.go") {
			continue
		}
		caller := callStack[0].SourceFile(true)
		e.Str("caller", caller)
		module = strings.SplitN(module, ".", 2)[0]
		e.Str("module", module)
		break
	}
}
```
2025-11-05 08:22:33 +01:00
..
2025-08-05 06:21:34 +02:00
2025-08-02 20:54:49 +02:00