Unicode string in SQL logs

10 views
Skip to first unread message

Arthur Fayzrakhmanov

unread,
Dec 3, 2021, 2:16:26 PM12/3/21
to Yesod Web Framework
Hi Haskellers!

Yesod loggs running SQL queries by default.  Log message shows SQL template and data list to be feed in it. 

However, when there are unicode string in data items log message are very unfriendly, 'cause such items represented as unicode sequences rather than human readable string.  This makes hard to debug what's happening when it's really needed.

Here is a quick example:

PersistText " \1085\1077 \1086\1073\1085\1072\1088\1091\1078\1077\1085\1099<br/>"

Is it possible to make logger more human friendly?  I would glad to make a PR (with some guidance) if such feature will be accepted by community.

jsch...@gmail.com

unread,
Dec 3, 2021, 4:52:00 PM12/3/21
to Yesod Web Framework
Are you using PostgreSQL? Then you could look at the SQL statements in the PostgreSQL log. Maybe that helps?

To enable that logs, for me it was only:

# log all sql statements to stderr -> journalctl -fu postgresql
log_statement = 'all'                   # none, ddl, mod, all

in /var/lib/{pgsql,postgresql}/data/postgresql.conf (the exact path depends on your distribution)

jsch...@gmail.com

unread,
Dec 3, 2021, 4:59:40 PM12/3/21
to Yesod Web Framework
Well, I didn't read carefully enough. Only read "hard to debug" ^^

Of course it would be nice if Yesod would log unicode directly in a cleaner way!

But it would be inconsistent to use show on all data items except on PersistText items... If someone would want to debug and use read to decode the debug output, that might not work, right?

Arthur Fayzrakhmanov

unread,
Dec 19, 2021, 5:50:11 AM12/19/21
to Yesod Web Framework
Thank you for hints!

суббота, 4 декабря 2021 г. в 02:59:40 UTC+5, jsch...@gmail.com:
Reply all
Reply to author
Forward
0 new messages