Skip to content

Logging: Multiple logs for a single query #5

@cvburgess

Description

@cvburgess

We are currently using https://github.com/khmm12/knex-tiny-logger for optional query logging but it does not seem to be working correctly. When making a single trip to the PostgreSQL database, it appears that multiple logs are created and the number per query goes up with every request. When logging the actual PostgreSQL database, it was verified that only a single request to the database is made.

TinyLogger Output:

SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (3.081 ms) select * from "tablename2"
SQL (3.081 ms) select * from "tablename2"
SQL (6.299 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (9.030 ms) select * from "tablename4" where "id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.389 ms) select * from "tablename6" where "id" = 2
SQL (7.808 ms) select * from "tablename6" where "id" = 2

PostgreSQL Logs:

LOG:  execute <unnamed>: select * from "tablename1" where "username" = '--username--'
LOG:  execute <unnamed>: select * from "tablename2"
LOG:  execute <unnamed>: select * from "tablename3" where "user_id" = 234
LOG:  execute <unnamed>: select * from "tablename4" where "id" in (1)
LOG:  execute <unnamed>: select * from "tablename5" where "tsg_id" in ($1)
LOG:  execute <unnamed>: select * from "tablename6" where "id" = 2

TinyLogger uses the .on method of knex - I'm not entirely sure if this is an issue with TinyLogger, Knex, or SQLDataSource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or not as expectedhelp wantedGreat issue to grab, help is appreciated!

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions