Apache HTTP服务器 - 如何在模块上打印到控制台

Apache HTTP Server - How to print to console on modules?

本文关键字:模块 打印 控制台 HTTP 服务器 Apache      更新时间:2023-10-16

我有一个apache http服务器模块,称为mod_mymodule.so在此处遵循文档。

我真的很想看到我自己的std::cout s,所以我可以在运行时看到我的模块正在加载以及内部发生的事情,例如:

static int myserver_handler(request_rec *r)
{
    std::cout << "WHY CAN'T I SEE THIS ON THE TERMINAL????" << std::endl; // <----????
    return OK;
}
static void register_hooks(apr_pool_t *pool)
{
    ap_hook_handler(myserver_handler, NULL, NULL, APR_HOOK_LAST);
}
module AP_MODULE_DECLARE_DATA   tofserver_module =
{
    STANDARD20_MODULE_STUFF,
    NULL,            // Per-directory configuration handler
    NULL,            // Merge handler for per-directory configurations
    NULL,            // Per-server configuration handler
    NULL,            // Merge handler for per-server configurations
    NULL,            // Any directives we may have for httpd
    register_hooks   // Our hook registering function
};

在调试模式下运行apache将输出到终端:

sudo apache2ctl -X