1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-13 00:07:30 +02:00

21 lines
449 B
Go
Raw Normal View History

2019-05-25 08:26:37 -05:00
package logger
import (
"context"
"fmt"
2019-08-17 10:58:45 -08:00
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
2019-05-25 08:26:37 -05:00
)
// WithContext manual injects context values to log message including Trace ID
func WithContext(ctx context.Context, msg string) string {
2019-08-17 10:58:45 -08:00
v, ok := ctx.Value(webcontext.KeyValues).(*webcontext.Values)
2019-05-25 08:26:37 -05:00
if !ok {
return msg
}
cm := fmt.Sprintf("dd.trace_id=%d dd.span_id=%d", v.TraceID, v.SpanID)
return cm + ": " + msg
}