abacaphiliac / doctrine-psr-sql-logger Goto Github PK
View Code? Open in Web Editor NEWPSR-3 Compliant Doctrine SQL Logger
License: MIT License
PSR-3 Compliant Doctrine SQL Logger
License: MIT License
First of all: thanks for this library, easy to use 👍
While using it, an idea popped into mind:
It might be nice to be able to determine the LogLevel dynamically, based on the query duration. Since the duration is only known when the query has finished, this derived LogLevel only applies for the "Query finished" log entry.
For example by handing over a "configuration array" instead of a fixed log-level:
$logLevelsForQueryDurationsInMilliseconds = [
0 => LogLevel::INFO, //default value: used for "Query started" and when no specific LogLevel applies, for this example up to 99 milliseconds
100 => LogLevel::NOTICE, //Used when a query takes more than 100 milliseconds (0.1 second)
500 => LogLevel::WARNING, //Used when a query takes more than 500 milliseconds (0.5 second)
1000 => LogLevel::CRITICAL, //Used when a query takes more than 1000 milliseconds (1 second)
];
What do you think? I can try to come up with a PR...
Started working on it here: https://github.com/holtkamp/doctrine-psr-sql-logger/tree/patch-psr-log-2-3
Will submit a PR when it is tested in a "real life" scenario / environment...
Currently the label used for query duration is duration_μs
:
For me μs
suggests that the value is indicated in microseconds, also see https://en.wikipedia.org/wiki/Microsecond
However, the value itself is indicated in seconds, only the level of detail is in microseconds.
So I would expect the label to be: duration_s
, or simply duration
...
Maybe a bit nitpicking 😉 , but it might be something to think about.
Currently when running a composer install
, doctrine/dbal
2.10.1
is installed, which uses a nullable ?array $params
parameter in the SQLLogger
interface: https://github.com/doctrine/dbal/blob/2.10/lib/Doctrine/DBAL/Logging/SQLLogger.php#L19
This is incompatible with:
php 7.0
, as currently required in composer.json
PsrSqlLogger::startQuery($sql, array $params = null, array $types = null)
signatureThe error message:
PHP Fatal error: Declaration of Abacaphiliac\Doctrine\PsrSqlParamsLogger::getStartQueryContext($sql, ?array $params = NULL, ?array $types = NULL) must be compatible with Abacaphiliac\Doctrine\PsrSqlLogger::getStartQueryContext($sql, ?array $params = NULL, ?array $types = NULL): array in /user/workspace/doctrine-psr-sql-logger/src/PsrSqlParamsLogger.php on line 7
It seems it doctrine/dbal
2.8
is the last version that does not use a nullable parameter: https://github.com/doctrine/dbal/blob/2.8/lib/Doctrine/DBAL/Logging/SQLLogger.php
TestLoggers are currently also available in psr/log
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.