monolog-mysql
monolog-mysql copied to clipboard
Removed unsetting of null values of $contentArray
Because however later they are added again with array_combine().
test.php file:
<?php
use MySQLHandler\MySQLHandler;
require __DIR__ . '/vendor/autoload.php';
putenv('DB_HOST=localhost');
putenv('DB_NAME=database');
putenv('DB_USER=user');
putenv('DB_PASS=password');
$conn = new PDO('mysql:host='.getenv('DB_HOST').';dbname='.getenv('DB_NAME'), getenv('DB_USER'), getenv('DB_PASS'));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$mySQLHandler = new MySQLHandler($conn, 'log', ['username', 'userid'], \Monolog\Logger::DEBUG);
$logger = new \Monolog\Logger( 'debug' );
$logger->pushHandler( $mySQLHandler );
$logger->addWarning('This is a great message, woohoo!', ['username' => 'John Doe', 'userid' => null]);
Command:
$ php -f test.php
Output:
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in .../monolog-mysql/vendor/wazaari/monolog-mysql/src/MySQLHandler/MySQLHandler.php:214
I tried running your example, but the situation is not reproducible, can you explain more?
Hello @frugan-it, I'll take a look into this and take it into consideration for the next release.
I've refactored the process in https://github.com/waza-ari/monolog-mysql/pull/47/commits/4eb4ad35a16ecf5e16701326fb6a419bedee4552 which should resolve this issue. Feel free to re-open the pull request if you want to point any additional problems.