db icon indicating copy to clipboard operation
db copied to clipboard

upper/db/v4 Logging source of line where SQL was executed

Open derkan opened this issue 5 years ago • 2 comments

Hi, As query logging is being run deferred;

	defer func(start time.Time) {
		queryLog(&QueryStatus{
			TxID:    sess.txID,
			SessID:  sess.sessID,
			Query:   query,
			Err:     err,
			Start:   start,
			End:     time.Now(),
			Context: ctx,
		})
	}(time.Now())

We lost caller file:line location. Because of this, current logger always prints location as ...sqladapter/session.go:647 which is meaningless.

func (c *loggingCollector) logf(level LogLevel, f string, v ...interface{}) {
	format := level.String() + "\n" + f
	if _, file, line, ok := runtime.Caller(2); ok {
		format = fmt.Sprintf("log_level=%s file=%s:%d\n%s", level, file, line, f)
	}
	format = "upper/db: " + format
...

I think we should respect logging as first-class.

derkan avatar Oct 02 '20 12:10 derkan

I found it was hard to look for useful information when the motst of the screen was full of stack output during development phase. Is that a way to turn off stack output?

hkhere avatar Jun 12 '22 00:06 hkhere

Hi @xiam, do you plan to work on this (you're self-assigned)? Or do you prefer reviewing a contribution from someone from the community at this time?

VojtechVitek avatar Jun 14 '22 09:06 VojtechVitek