#include inherit "module"; inherit "caudiumlib"; constant module_type = MODULE_LOGGER; constant module_name = "Sample Logger module"; constant module_doc = "Sample Logger module to show how Logging system" " in Caudium."; void create() { defvar("logfile","/var/log/httpd/httpd.log","Log file", TYPE_STRING, "This is the file where is logged all clients accesses.\n"); } // Used to have the opened file access when logging for speed object logf; void start() { object c=Stdio.File(); logf=0; // Reset the old value, if any.. if(!(c->open(QUERY(logfile), "wca"))) report_error("Clientlogger: Cannot open logfile.\n"); else logf = c; } void stop() { logf->close(); } /* * function log, * * This function log the access from client according to his request id * */ void log(object id, mapping file) { logf->write(caudium->quick_ip_to_host(id->remoteaddr) + " " + (sizeof(id->referer)?id->referer[0]:"-") + " - ["+ cern_http_date(id->time) + "] \"" + id->method + " " + id->raw_url + " " + id->clientprot + "\" " + (file->error||200) + " " + file->len +"\n"); }