Skip to content

Commit faa0a10

Browse files
committed
add flag to disable logging
1 parent 49c9131 commit faa0a10

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ You may use the following code block below as a template, which has some good de
7979
'protocol' => env('DB_PROTOCOL', 'https'),
8080
'cache_session_token' => env('DB_CACHE_SESSION_TOKEN', true), // set to false to log out after each reqeust. This can be slower than re-using a session token, but allows for globals to be set for individual user values.
8181
'empty_strings_to_null' => env('DB_EMPTY_STRINGS_TO_NULL', true), // set to false to return empty strings instead of null values when fields are empty in FileMaker
82+
'enable_query_logging' => env('FM_ENABLE_QUERY_LOGGING', true), // set to false to disable query logging
8283
]
8384
```
8485
You should add one database connection configuration for each FileMaker database you will be connecting to. Each file can have completely different configurations, and can even be on different servers.

src/Services/FileMakerConnection.php

+7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ class FileMakerConnection extends Connection
4141

4242
protected bool $emptyStringToNull = true;
4343

44+
protected bool $enableLogging = true;
45+
4446
public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
4547
{
4648

4749
$this->emptyStringToNull = $config['empty_strings_to_null'] ?? true;
4850
$this->shouldCacheSessionToken = $config['cache_session_token'] ?? true;
51+
$this->enableLogging = $config['enable_logging'] ?? true;
4952

5053
// set the session cache key with the name of the connection to support multiple connections
5154
$this->sessionTokenCacheKey = 'eloquent-filemaker-session-token-' . $config['name'];
@@ -751,6 +754,10 @@ protected function makeRequest($method, $url, $params = [], ?PendingRequest $req
751754

752755
protected function logFMQuery($method, $url, $params, $start)
753756
{
757+
if (! $this->enableLogging) {
758+
return;
759+
}
760+
754761
$commandType = $this->getSqlCommandType($method, $url);
755762

756763
// Clockwork specifically looks for the commandType as the first word in the "sql" string

0 commit comments

Comments
 (0)