Giter Club home page Giter Club logo

doctrine-psr-sql-logger's People

Contributors

abacaphiliac avatar holtkamp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

doctrine-psr-sql-logger's Issues

Suggestion: allow to configure LogLevel based on query duration

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...

Misleading label for query duration: "duration_μs"

Currently the label used for query duration is duration_μs:

'duration_μs' => $stop - $this->start,

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.

Upper limit required for Doctrine/DBAL

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
  • the current PsrSqlLogger::startQuery($sql, array $params = null, array $types = null) signature

The 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.