query-log doc
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Phramework
    • QueryLog

Classes

  • QueryLog
  • QueryLogAdapter

Class QueryLog

This package wraps phramework's database adapter and keeps logs of the executed queries and it's parameters. The presence of this package once activated won't affect the rest of the system.
Defined settings:

  • boolean disabled, [Optional], default is false
  • object database, database settings
    • string adapter, IAdapter's implementation class path
      Example:
      'adapter' => 'Phramework\\Database\\MySQL',
    • string name, Database name
    • string username
    • string password
    • string host
    • integer port
    • string table, [Optional], Table name, default is `"query_log"`
    • string schema, [Optional], Tables schema, default is null
  • object matrix, [Optional], Log level matrix, using this matrix queries from specific or all class methods can be excluded from logging. The log will be excluded if the above have a non positive value and they are contained in the current backtrace.
    Example:
    'matrix' => (object)[
          'MyNamespace\\MyClass' => false,
          'MyNamespace\\MySecondClass' => (object)[
              'GET' => false
          ],
      ],
Namespace: Phramework\QueryLog
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Example:


//Let's assume $settings is global phramework's settings array

//... After the use of \Phramework\Database\Database::setAdapter method,
//the global adapter is initialized

//Now we can create a QueryLog object
$queryLog = new \Phramework\QueryLog\QueryLog($settings['query-log']);

//And register this object, using additional parameters.
$queryLog->register(['API' => 'base']);

//Now we can invoke phramework's instance

//Queries executed from this point forward are now logged based on the provided rules

//Execute API
$phramework->invoke();

Located at QueryLog.php

Methods summary

public
# __construct( object $settings )

Create a new query-log instance

Create a new query-log instance

Parameters

$settings
Settings array

Throws

Exception
When database adapter is not set
Phramework\Exceptions\ServerException

When database setting isn't defined in given settings parameter

Todo

Add log level matrix
public boolean
# register( null|object|array $additionalParameters = null )

Activate query-log

Activate query-log

Parameters

$additionalParameters
Additional parameters to be stored in query logs

Returns

boolean
Returns false if query log is disabled

Properties summary

protected array $settings
#
query-log doc API documentation generated by ApiGen