Closed stormenergy91 closed 1 year ago
Hi @stormenergy91
I just tested it and it worked perfectly with my environment. However, I guess I understand what happened in your environment. Could you please post the output of buffalo info
so we can verify if this is the case? (Actually, this is mandatory for bug reports)
By the way, the hint is your log output. This is not the format of Buffalo's logger but the default format of Pop, which means the logs were printed not by Buffalo but by Pop.
Recently, we changed Pop's logging system to include connection/transaction information (ID) when it prints SQL logs. See gobuffalo/pop/issues/794 and gobuffalo/pop/issues/795 for details.
After the change on Pop, we decoupled Buffalo and Pop completely, then fixed Buffalo-pop's logging feature to support the new transaction-aware logging system to make them work together properly. (gobuffalo/buffalo-pop/pull/77)
Please check your go.mod
and make your app uses Pop v6.1.0 or higher and Buffalo-pop v3.0.7. It may fix the issue.
If the issue is not fixed with the version update, please let me know and post your result of buffalo info
and the full log output.
Thanks @sio4 for your help.
I confirm that all warning messages are related to SQL operations so I think is a Pop probleme. I check my project and Pop
and Buffalo-Pop
are already at the last version. But in any case I'll the the warnign message with LogLvl
set to ErrorLevel
Here thebuffalo info
:
I also add the warnig message when populate data in a custom User model:
POP] 2023/03/07 09:46:45 sql - BEGIN Transaction --- (conn=tx-7122446591380708498, tx=7122446591380708498)
Creating Admin User...
[POP] 2023/03/07 09:46:45 sql - INSERT INTO "users" ("avatar", "created_at", "email", "first_name", "id", "is_mail_active", "is_mobile_active", "is_staff", "is_superuser", "last_name", "mobile", "password_hash", "send_email_notifications", "send_web_notifications", "updated_at") VALUES (:avatar, :created_at, :email, :first_name, :id, :is_mail_active, :is_mobile_active, :is_staff, :is_superuser, :last_name, :mobile, :password_hash, :send_email_notifications, :send_web_notifications, :updated_at) | [{"id":"148cc4bf-8f51-4d6e-b4bb-dc696dc64538","first_name":"Utente","last_name":"Admin","mobile":"","email":"sandbox@stormenergy.com","password_hash":"$2a$10$VQgkOI77x5CusHpHEnLtYOfoeish1x.p3mWNpIUrc7DGD1c9o0i6y","is_staff":true,"is_superuser":true,"is_mobile_active":true,"is_mail_active":true,"avatar":"","send_web_notifications":false,"send_email_notifications":false,"created_at":"2023-03-07T09:46:45.301015+01:00","updated_at":"2023-03-07T09:46:45.301015+01:00"}] (conn=tx-7122446591380708498, tx=7122446591380708498)
[POP] 2023/03/07 09:46:45 sql - UPDATE "users" AS users SET "avatar" = :avatar, "email" = :email, "first_name" = :first_name, "is_mail_active" = :is_mail_active, "is_mobile_active" = :is_mobile_active, "is_staff" = :is_staff, "is_superuser" = :is_superuser, "last_name" = :last_name, "mobile" = :mobile, "password_hash" = :password_hash, "send_email_notifications" = :send_email_notifications, "send_web_notifications" = :send_web_notifications, "updated_at" = :updated_at WHERE users.id = :id | ["148cc4bf-8f51-4d6e-b4bb-dc696dc64538"] (conn=tx-7122446591380708498, tx=7122446591380708498)
Done
[POP] 2023/03/07 09:46:47 sql - END Transaction --- (conn=tx-7122446591380708498, tx=7122446591380708498)
Indeed, this is weird.
You already use Pop v6.1.1 and Buffalo-pop v3.0.7 in your go.mod
. Also, the output you posted recently is the form of Pop's new logger which contains conn=
and tx=
, and the tx=
has a non-zero value which means you use Transaction.
What I wonder is the sentence you wrote: "when populate data in a custom User model". Do you also see this kind of log when you just query any existing data for your model or just call a handler that does not use a database? The reason I asking this is:
So I wonder if you use buffalo-pop middleware or use Pop transaction directly for finer control. If the later is your case, I would like to ask you to check how you configure the logging feature of Pop. With this change, we introduced a new Function to set TxLogger
(logger for SQL executions) and you can set the logger with the following function.
Could you please check your app.go
if you disabled pop transactions by default or related files and let me know what happened? If this is not your case, please provide us with your actions/app.go
and models/models.go
.
PS. I edited your last comment to make it short in the conversation history by adding <details>
and </details>
to make the long output to be collapsible. Also please make sure there is no real PII in your log posted before.
Yes I'm using transaction, in my app.go
there is:
app.Use(popmw.Transaction(models.DB))
app.Use(translations())
So i tried to set the custom logger with SetTxLogger
but I don't understand how to implemt it. There is some example?
PS:
Thanks for add details
tag
Hmm, interesting. The first line of the quoted code in the last comment, popmw.Transaction()
should set the logger inside it (gobuffalo/buffalo-pop/pull/77) so the tx aware logger of the App should be used for Pop too.
app.go
[POP] 2023/03/07 09:46:45 sql - BEGIN Transaction --- (conn=tx-7122446591380708498, tx=7122446591380708498)
FYI, the log should be in the format of the following if the App's log is applied correctly and the log level is Debug.
DEBU[2023-03-09T09:58:45+09:00] BEGIN Transaction --- conn=tx-4102281454373580993 tx=4102281454373580993
DEBU[2023-03-09T09:58:45+09:00] END Transaction --- conn=tx-4102281454373580993 tx=4102281454373580993
INFO[2023-03-09T09:58:45+09:00] / conn=tx-4102281454373580993 content_type=text/html <...>
(I cannot reproduce the issue)
After some research I founded what was the problem. The Pop log info are generated only in my grifts
scripts. In this scripts i use the DB
var configured in models/models.go
and i see that now there is a new line pop.Debug = env == "development"
, If i comment this line no more log info.
Thansk anyway for the support!
Ah! got it! Thank you for sharing the details!
@sio4 I noticed that if you build a project with buffalo build
and than you do ./nameproject migrate
you get all the pop info:
...
[POP] 2023/03/29 09:48:48 info - Successfully applied 44 migrations.
[POP] 2023/03/29 09:48:48 info - 0.2438 seconds
...
How I can disable POP logs also in migrate command? I don't want that this info are aviable in production builds.
Thanks
How I can disable POP logs also in migrate command? I don't want that this info are aviable in production builds.
Ah! Good point! However, there is no method to disable it for now. One possible workaround is redirecting the standard error to /dev/null
since the log will be printed to the standard error. (coke migrate 2>/dev/null
).
Could it be feasible for your condition? By the way, what is the reason for suppressing those logs? Does it break something? While I understand having more control is better for users, I wonder which specific case it affects badly.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment. Otherwise, this will be closed in 7 days.
This issue was closed because it has been stalled for 30+7 days with no activity.
Description
By default all Buffalo projects have warning log. Since the last version (1.1.0) it was simply add this property in the App class definition and change the Log Level:
But with the last release this seems to be ingored and always the warning errors are visible:
To Reproduce
Change LogLvl in App Class
Additional Context
No response