Skip to content

logger/slog output source file depth is incorrect #7609

@ifooth

Description

@ifooth

GORM Playground Link

go-gorm/playground#833

Description

gorm logger is a great interface, with slog, the functionality is now more extensible,we can append trace/request_id attr, change source file format, output to json as we need

but when i use, logger/slog has a issue with caller source file depth

logger/log work fine
Image

logger/slog source file not correct
Image

Solution

by now, The official golang community explicitly does not support depth

ref issue
golang/go#73707
golang/go#59145

so i initiate a pr, abstract a common function named CallerFrame use by FileWithLineNum and slog

logger/slog after fix
Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions