[GH-ISSUE #87] Adding logging when using sqlite as storage backend? #55

Closed
opened 2026-05-23 08:28:30 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @Darkle on GitHub (Mar 19, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/87

Hi, when in development there are often times when I would like to log all db queries to the console. This is of course doable with the native acebase storage using the log option, but that feature isnt available when using sqlite as a storage backend.

I was wondering if it would be possible to add logging when using sqlite as a storage backend with acebase. It seems that the sqlite3 library that acebase is using supports logging the db queries via the Database#on('trace', [callback]) api mentioned here: https://github.com/mapbox/node-sqlite3/wiki/Debugging#databaseontrace-callback

I also found this thread for mysql, perhaps a logging option could be enabled for both?

Cheers.

Originally created by @Darkle on GitHub (Mar 19, 2022). Original GitHub issue: https://github.com/appy-one/acebase/issues/87 Hi, when in development there are often times when I would like to log all db queries to the console. This is of course doable with the native acebase storage using the log option, but that feature isnt available when using sqlite as a storage backend. I was wondering if it would be possible to add logging when using sqlite as a storage backend with acebase. It seems that the sqlite3 library that acebase is using supports logging the db queries via the `Database#on('trace', [callback])` api mentioned here: https://github.com/mapbox/node-sqlite3/wiki/Debugging#databaseontrace-callback I also found [this thread for mysql](https://github.com/mysqljs/mysql/issues/1272), perhaps a logging option could be enabled for both? Cheers.
Author
Owner

@appy-one commented on GitHub (Mar 20, 2022):

I think it would be a nice feature to implement, but there currently is no query logging implemented. The logLevel setting works for all storage engines, but that's for console logging of internal operations. The sqlite storage engine will log other messages than default storage because it operates differently. If you are referring to transaction logging, which is only available for binary storage: that's something else. Transaction logging writes all data mutations to a separate log file to provide enhanced data synchronization and recovery options.

Long story short: there is no query logging.

What you can do though, is manually logging query stats and hints by adding a .on('stats', stats => console.log(stats)) and .on('hints', hints => console.log(hints)) to your queries.

<!-- gh-comment-id:1073203390 --> @appy-one commented on GitHub (Mar 20, 2022): I think it would be a nice feature to implement, but there currently is no query logging implemented. The logLevel setting works for all storage engines, but that's for console logging of internal operations. The sqlite storage engine will log other messages than default storage because it operates differently. If you are referring to transaction logging, which is only available for binary storage: that's something else. Transaction logging writes all data mutations to a separate log file to provide enhanced data synchronization and recovery options. Long story short: there is no query logging. What you can do though, is manually logging query stats and hints by adding a `.on('stats', stats => console.log(stats))` and `.on('hints', hints => console.log(hints))` to your queries.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#55
No description provided.