Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to print real line of code #73

Open
BlackSinny opened this issue Jun 21, 2023 · 0 comments
Open

how to print real line of code #73

BlackSinny opened this issue Jun 21, 2023 · 0 comments

Comments

@BlackSinny
Copy link

my code like this

        db, err := sqlx.Connect("mysql", dbURL)
	if err != nil {
		//todo handle error
	}
	var writers []io.Writer
	writers = append(writers, zerolog.ConsoleWriter{Out: os.Stderr})
	mw := io.MultiWriter(writers...)
	logger := zerolog.New(mw).With().Timestamp().Caller().Logger()
	loggerOptions := []sqldblogger.Option{
		sqldblogger.WithSQLQueryFieldname("sql"),
		sqldblogger.WithWrapResult(true),
		sqldblogger.WithLogDriverErrorSkip(false),
		sqldblogger.WithPreparerLevel(sqldblogger.LevelDebug),
		sqldblogger.WithQueryerLevel(sqldblogger.LevelInfo),
		sqldblogger.WithExecerLevel(sqldblogger.LevelInfo),
	}
	sqlDB := sqldblogger.OpenDriver(dbURL, db.Driver(), zerologadapter.New(logger), loggerOptions...)
	db = sqlx.NewDb(sqlDB, "mysql")

output log like

4:10PM INF github.com/simukti/sqldb-logger/logadapter/zerologadapter@v0.0.0-20230108155151-646c1a075551/logger.go:38

not the lines of code that actually execute sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant