mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Merge pull request #2102 from selfhost-alt/sqlite-query-logging
Add ability to enable DEV logs of Sqlite queries
This commit is contained in:
commit
97b0b98605
@ -166,10 +166,25 @@ class Database {
|
|||||||
*/
|
*/
|
||||||
async connect() {
|
async connect() {
|
||||||
Logger.info(`[Database] Initializing db at "${this.dbPath}"`)
|
Logger.info(`[Database] Initializing db at "${this.dbPath}"`)
|
||||||
|
|
||||||
|
let logging = false
|
||||||
|
let benchmark = false
|
||||||
|
if (process.env.QUERY_LOGGING === "log") {
|
||||||
|
// Setting QUERY_LOGGING=log will log all Sequelize queries before they run
|
||||||
|
Logger.info(`[Database] Query logging enabled`)
|
||||||
|
logging = (query) => Logger.dev(`Running the following query:\n ${query}`)
|
||||||
|
} else if (process.env.QUERY_LOGGING === "benchmark") {
|
||||||
|
// Setting QUERY_LOGGING=benchmark will log all Sequelize queries and their execution times, after they run
|
||||||
|
Logger.info(`[Database] Query benchmarking enabled"`)
|
||||||
|
logging = (query, time) => Logger.dev(`Ran the following query in ${time}ms:\n ${query}`)
|
||||||
|
benchmark = true
|
||||||
|
}
|
||||||
|
|
||||||
this.sequelize = new Sequelize({
|
this.sequelize = new Sequelize({
|
||||||
dialect: 'sqlite',
|
dialect: 'sqlite',
|
||||||
storage: this.dbPath,
|
storage: this.dbPath,
|
||||||
logging: false,
|
logging: logging,
|
||||||
|
benchmark: benchmark,
|
||||||
transactionType: 'IMMEDIATE'
|
transactionType: 'IMMEDIATE'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user