I have been refactoring a project and I have seen a class named Logger
. I assume this is deprecated and unneeded. I have searched for references of it and I have seen a single code fragment, which uses it:
fCore::registerDebugCallback('Logger::log');
// Enable SQL statement printing
//
$db->enableDebugging(App::env()->get('slowQueryLog'));
$db->registerHookCallback('extracted', 'Logger::queryLogPrepare');
$db->registerHookCallback('run', 'Logger::queryLog');
I see its methods are registered as callbacks. I believe these are unnecessary and I would like to remove them to be able to remove the Logger
class. However, the only way I can properly test it is to remove the part above and deploy it. This code is used by a large website, so if my assumption is wrong, then there would be a lot of damage. So, even though it would be easy to test, I would like to not face the danger of removing the chunk and getting thousands of angry emails and I reach out to you guys and ask you: is flourishlib requiring to register callbacks for debug and/or hook? For your reference I give you the relevant parts of the documentation:
registerDebugCallback:
/**
* Registers a callback to handle debug messages instead of the default action of calling ::expose() on the message
*
* @param callback $callback A callback that accepts a single parameter, the string debug message to handle
* @return void
*/
registerHookCallback:
/**
* Registers a callback for one of the various query hooks - multiple callbacks can be registered for each hook
*
* The following hooks are available:
* - `'unmodified'`: The original SQL passed to fDatabase, for prepared statements this is called just once before the fStatement object is created
* - `'extracted'`: The SQL after all non-empty strings have been extracted and replaced with ordered sprintf-style placeholders
* - `'run'`: After the SQL has been run
*
* Methods for the `'unmodified'` hook should have the following signature:
*
* - **`$database`**: The fDatabase instance
* - **`&$sql`**: The original, unedited SQL
* - **`&$values`**: The values to be escaped into the placeholders in the SQL
*
* Methods for the `'extracted'` hook should have the following signature:
*
* - **`$database`**: The fDatabase instance
* - **`&$sql`**: The SQL with all strings removed and replaced with `%1$s`-style placeholders
* - **`&$values`**: The values to be escaped into the placeholders in the SQL
*
* The `extracted` hook is the best place to modify the SQL since there is
* no risk of breaking string literals. Please note that there may be empty
* strings (`''`) present in the SQL since some databases treat those as
* `NULL`.
*
* Methods for the `'run'` hook should have the following signature:
*
* - **`$database`**: The fDatabase instance
* - **`$query`**: The (string) SQL or `array(0 => {fStatement object}, 1 => {values array})`
* - **`$query_time`**: The (float) number of seconds the query took
* - **`$result`** The fResult or fUnbufferedResult object, or `FALSE` if no result
*
* @param string $hook The hook to register for
* @param callback $callback The callback to register - see the method description for details about the method signature
* @return void
*/