drz5553 2015-06-30 11:41
浏览 16

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

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
 */
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?