engine.ShowError not available anymore? #649
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#649
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In the documentation (https://github.com/coscms/xorm/blob/master/docs/QuickStart.md > Section 1: Create ORM Engine > 1.Logs)
I saw that there was/is an
engine.ShowError = true
. However the ShowError is not an attribute / method anymore. Also I don't find it anywhere in the code.Did this dissapear? If so, why? And could you bring it back?
Other than that, really enjoying the library. Big kudos :)!
Yes, we have upgrade the usage. This is not compitable with old version. The document is too old that I will update it later. Now you have to
engine.SetLogger()
and set the log level. You can use your favorite logger to do that sincecore.ILogger
is an interface.Hi @lunny , thanks for the fast answer!
I just tried
engine.SetLogger(xorm.NewSimpleLogger3(os.Stdout, "[db]", log.Ldate|log.Lmicroseconds|log.LUTC, core.LOG_ERR))
However this does not show errors for queries that failed (e.g. when incorrect column name). How can I solve this?
Engine.ShowSQL(true) will record SQL into logger as info log level
Hi Lunny, it seems we are talking about something different.
I want to show the Postgresql errors as they occur without having to
_, err := db.Insert()
,fmt.Println(err)
for example.I played a bit with
Engine.ShowSQL(true)
and with differentcore.loglevels
. From the moment I putcore.LOG_INFO
I see all the queries being executed but still no messages for failed queries.So the ideal scenario for me is.
Can I achieve that with the logger? and if not, how do you suggest to go about?
@pjmuller if Postgresql return en error, xorm will return the error via err on
_, err := db.Insert()
so you have to show the error yourself.You can show the last SQL via
session.LastSQL()
after you executeFind, Insert
and etc.Hi @lunny , thanks for the
session.LastSQL()
info.Do you see a way to hook into that error? So that I don't have to do always do
_, err := ...
Writing a wrapper is hard without forking the project (as I can't extend the Engine type). Would loved to have solved this with a logger or alike. Any ideas?
I'm afraid there is no the hook to do that. And currently I have no idea about how to add a hook satisfied with this.