0
我是一个非常天真的编程学生,对于lighttpd来说绝对是新的。我想了解一个简单的“Hello world”插件是如何构建的。我从书中找到了代码。代码如下。困惑的log_trace函数
#includes "base.h"
#includes "log.h"
#includes "plugin.h"
#ifdef HAVE_CONFIG_H
#includes "config.h"
#endif
typedef struct { PLUGIN_DATA; /* no config */ } plugin_data;
INIT_FUNC(mod_helloworld_init) {
plugin_data *p;
UNUSED(srv);
p = calloc(1, sizeof(*p));
log_trace("Hello, World!");
return p;
}
FREE_FUNC(mod_helloworld_free) {
plugin_data *p = p_d;
UNUSED(srv);
if (p) free(p);
return HANDLER_GO_ON;
}
int mod_helloworld_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = buffer_init_string("helloworld");
p->init = mod_helloworld_init;
p->cleanup = mod_helloworld_free;
p->data = NULL;
return 0;
}
在上面提到的代码中,我不明白函数“log_trace”是如何工作的。我发现它不是C++中的预定义函数。它似乎必须由程序员自己写。你能解释它是如何工作的?
该头文件包含以下 的#ifndef _LOG_H_ 的#define _LOG_H_ 的#include “server.h” /*关闭FD和_try_获得的/ dev/null的它来代替。 *成功时返回0,失败时返回-1(在任何情况下fd都关闭) */ int openDevNull(int fd); #define WP()log_error_write(srv,__FILE__,__LINE__,“”); int open_logfile_or_pipe(server * srv,const char * logfile); int log_error_open(server * srv); int log_error_close(server * srv); int log_error_write(server * srv,const char * filename,unsigned int line,const char * fmt,...); int log_error_cycle(server * srv); #endif – 2012-03-28 10:11:27
我不能'看到任何关于它的log_trace。 – 2012-03-28 10:13:53