<commit_before>package sentry

import (
	"fmt"
	"strings"

	apex "github.com/francoishill/log"
	"github.com/francoishill/log/handlers/level"
	raven "github.com/getsentry/raven-go"
)

//NewLogHandler returns a new logger that logs to sentry
func NewLogHandler(client *raven.Client, logLevel apex.Level) apex.Handler {
	sentryLogger := &logger{client: client}
	return level.New(sentryLogger, logLevel)
}

type logger struct {
	client *raven.Client
}

var severityMapping = [...]raven.Severity{
	apex.DebugLevel:     raven.DEBUG,
	apex.InfoLevel:      raven.INFO,
	apex.NoticeLevel:    raven.WARNING,
	apex.WarnLevel:      raven.WARNING,
	apex.ErrorLevel:     raven.ERROR,
	apex.CriticalLevel:  raven.FATAL,
	apex.AlertLevel:     raven.FATAL,
	apex.EmergencyLevel: raven.FATAL,
}

func (l *logger) HandleLog(e *apex.Entry) error {
	var err error
	var stack interface{}

	tags := map[string]string{}
	for key, val := range e.Fields {
		if strings.EqualFold(key, "stack") {
			stack = val
			continue //stack added below
		}

		if strings.EqualFold(key, "error") {
			if tmpErr, ok := val.(error); ok {
				err = tmpErr
			}
		}

		tags[key] = fmt.Sprintf("%+v", val)
	}

	packet := raven.NewPacket(e.Message)
	packet.Init("") //will setup default fields like project, culprit, etc
	packet.Level = severityMapping[e.Level]

	if stack != nil {
		packet.Extra["stack"] = stack
	}
	if err != nil {
		packet.Extra["full-error"] = fmt.Sprintf("%+v", err)
	}<commit_msg>feat: sentry logger now use `%v` for all tags and `%+v` for Extra<commit_after>package sentry

import (
	"fmt"

	apex "github.com/francoishill/log"
	"github.com/francoishill/log/handlers/level"
	raven "github.com/getsentry/raven-go"
)

//NewLogHandler returns a new logger that logs to sentry
func NewLogHandler(client *raven.Client, logLevel apex.Level) apex.Handler {
	sentryLogger := &logger{client: client}
	return level.New(sentryLogger, logLevel)
}

type logger struct {
	client *raven.Client
}

var severityMapping = [...]raven.Severity{
	apex.DebugLevel:     raven.DEBUG,
	apex.InfoLevel:      raven.INFO,
	apex.NoticeLevel:    raven.WARNING,
	apex.WarnLevel:      raven.WARNING,
	apex.ErrorLevel:     raven.ERROR,
	apex.CriticalLevel:  raven.FATAL,
	apex.AlertLevel:     raven.FATAL,
	apex.EmergencyLevel: raven.FATAL,
}

func (l *logger) HandleLog(e *apex.Entry) error {
	packet := raven.NewPacket(e.Message)
	packet.Init("") //will setup default fields like project, culprit, etc
	packet.Level = severityMapping[e.Level]

	tags := map[string]string{}
	for key, val := range e.Fields {
		tags[key] = fmt.Sprintf("%v", val)
		packet.Extra["full-"+key] = fmt.Sprintf("%+v", val)
	}
{'fraction_non_alphanumeric': 0.13935045317220543, 'fraction_numerical': 0.0, 'mean_word_length': 3.9793233082706765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2454630', 'n_tokens_mistral': 1023, 'n_tokens_neox': 973, 'n_words': 218}