Announcement

Collapse
No announcement yet.

Log the user with each SQL query

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Log the user with each SQL query

    Is it possible to log the user which is responsible for generating and executing each SQL query? I am logging the query already, but I am not sure how to get the logged in user's name. Ideally, I would have something like this:

    Code:
    $GLOBALS['log']->debug('User: $user, SQL: $sql');
    I'm not sure if that is possible or where it should go. The SQL is being logged in application/Espo/ORM/DB/Query/Base.php; is that still the right place to do this?

  • #2

    Most queries are executed in 2 files:

    application/Espo/ORM/DB/Query/Base.php
    application/Espo/ORM/DB/Mapper.php

    Comment


    • #3
      Normally I would use $this->getUser(), if it is defined. When in static context I get the username like this: $GLOBALS['app']->getContainer()->get('user')->get('username');

      Comment

      Working...
      X