0

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
 */
leppie
  • 115,091
  • 17
  • 196
  • 297
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • @leppie, are you sure this question is PHP-related? flourishlib is a PHP library indeed, but the question itself is wondering about things inside flourishlib and not about standard PHP. If so, then in the future every time I ask a question related to flourishlib, I should add the tag of PHP as well. Isn't this redundant? – Lajos Arpad Jun 30 '15 at 12:27
  • 1
    No, this is not redundant at all. PHP can be considered the major category of the tag. Tagging as PHP will highlight it to others using PHP and hide it from those that ignore PHP. – leppie Jun 30 '15 at 12:31
  • 1
    I still believe it is redundant, since flourishlib => php, however, your point is valid and you convinced me. A person not interested about php would not necessary know about flourishlib and would read the question, being frustrated about the content, which is garbage from his/her perspective. So, I hear you and I stand corrected. – Lajos Arpad Jun 30 '15 at 12:47

0 Answers0