Comments (9)
Did you try implementing the on OnErrorer
[1] interface?
[1]: https://github.com/gchaincl/sqlhooks/blob/master/sqlhooks.go#L21
from sqlhooks.
thanks for your response. it worked!
from sqlhooks.
Sorry, now i have a new problem. Sometimes error log will print twice and i can't find the reason.
from sqlhooks.
can u send the code
from sqlhooks.
func (h *Hooks) OnError(ctx context.Context, err error, query string, args ...interface{}) error {
begin := ctx.Value("begin").(time.Time)
var traceLog string
res := ctx.Value("traceLog")
if res != nil {
traceLog = res.(string)
} else {
traceLog, _ = shortid.Generate()
}
l := clog.NewWithCtx(traceLog)
l.Info("SQL | %10s | %s %v", utils.FormatDuration(time.Since(begin)), query, args)
return err
}
then error sql will log twice.
from sqlhooks.
could you just try to print a single like in the OnError
hook?
so that we can be sure that the problem is with the hook and not with your logger?
from sqlhooks.
thanks for your response. now i think the problem is not with the hook. i use sqlx, then whatever sql is right or wrong, sqlx throws a driver.ErrSkip error and OnError func will exec, so if sql is right, it will print twice.Do you know how to solve itοΌ
error: driver: skip fast-path; continue as if unimplemented
from sqlhooks.
can you fmt.Printf("error: %+v (%T)", err, err)
on the hook.
If the errors are different you can act differently depending on the error you get
from sqlhooks.
thanks for your response, but unfortunately, the errors is the same.
error: driver: skip fast-path; continue as if unimplemented (*errors.errorString)
from sqlhooks.
Related Issues (20)
- Add Error handler
- Improve performance HOT 13
- Compose hook HOT 4
- Before+after hooks for prepare HOT 1
- Tag latest commit HOT 3
- Include Go version requirement in README HOT 3
- Issues with gorm HOT 3
- can't use transactions with sqlhooks HOT 6
- QueryerContext interface and prepared statements HOT 1
- Actual resulting query? HOT 9
- SQL commands inside hook methods HOT 1
- Run a linter in the CI HOT 2
- driver.ErrSkip error with sqlx HOT 4
- add sqlhooks on awesome-go
- [Discussion] onError hook error ignore HOT 4
- when using wraper driver, table name has Double quotes HOT 1
- How get the query's Result on After Hook? HOT 1
- runtime error: comparing uncomparable type mssql.Error HOT 4
- Add Benchmarks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlhooks.