flourishlib是否需要注册调试回调或注册钩子回调?

时间:2015-06-30 11:41:36

标签: php flourishlib

我一直在重构一个项目,我看到了一个名为Logger的类。我认为这已被弃用且不需要。我搜索了它的引用,我看到了一个代码片段,它使用它:

fCore::registerDebugCallback('Logger::log');

// Enable SQL statement printing
//
$db->enableDebugging(App::env()->get('slowQueryLog'));
$db->registerHookCallback('extracted', 'Logger::queryLogPrepare');
$db->registerHookCallback('run', 'Logger::queryLog');

我看到它的方法被注册为回调。我相信这些是不必要的,我想删除它们以便能够删除Logger类。但是,我能够正确测试它的唯一方法是删除上面的部分并进行部署。这个代码被一个大型网站使用,所以如果我的假设是错误的,那么就会有很多损害。所以,即使它很容易测试,我也不想面对删除大块并收到成千上万的愤怒电子邮件的危险,我会联系你们并问你们:是否需要注册调试和/的回调或钩?供您参考,我将为您提供文档的相关部分:

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
 */

0 个答案:

没有答案