- From: "Xavier Beaudouin" <kiwi AT cvs.caudiumforge.net>
- To: caudium-commits AT caudium.net
- Subject: CVS: caudium/server/modules/vhs vhs_syslogger.pike,1.1.2.1,1.1.2.2
- Date: Thu, 18 Aug 2005 19:24:35 +0000
Update of /cvs/caudium/caudium/server/modules/vhs
In directory cvs.caudiumforge.net:/tmp/cvs-serv25812/server/modules/vhs
Modified Files:
Tag: stable_1_2
vhs_syslogger.pike
Log Message:
VHS Syslogger is now working. :p
Updated some defvar.
Index: vhs_syslogger.pike
===================================================================
RCS file: /cvs/caudium/caudium/server/modules/vhs/Attic/vhs_syslogger.pike,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- vhs_syslogger.pike 18 Aug 2005 16:15:05 -0000 1.1.2.1
+++ vhs_syslogger.pike 18 Aug 2005 19:24:33 -0000 1.1.2.2
@@ -19,21 +19,21 @@
*
*/
/*
- * $Id: vhs_syslogger.pike,v 1.1.2.1 2005/08/18 16:15:05 kiwi Exp $
+ * $Id: vhs_syslogger.pike,v 1.1.2.2 2005/08/18 19:24:33 kiwi Exp $
*/
//! module: VHS - Syslogger module
//! This module logs the accesses of each vitual in VHS using Syslog
//! inherits: module
//! inherits: caudiumlib
//! type: MODULE_LOGGER
-//! cvs_version: $Id: vhs_syslogger.pike,v 1.1.2.1 2005/08/18 16:15:05 kiwi
Exp $
+//! cvs_version: $Id: vhs_syslogger.pike,v 1.1.2.2 2005/08/18 19:24:33 kiwi
Exp $
/* Based on user logging module */
-constant cvs_version = "$Id: vhs_syslogger.pike,v 1.1.2.1 2005/08/18
16:15:05 kiwi Exp $";
+constant cvs_version = "$Id: vhs_syslogger.pike,v 1.1.2.2 2005/08/18
19:24:33 kiwi Exp $";
constant thread_safe = 1;
-#define VHSYSLOG_DEBUG 1
+//#define VHSYSLOG_DEBUG 1
#ifdef VHSYSLOG_DEBUG
#define DW(x) werror("[VHS_syslogger] " + x + "\n")
@@ -126,6 +126,8 @@
foreach(foo, b)
if(strlen(b) && b[0] != '#' && sizeof(b/":")>1)
log_format[(b/":")[0]] = fix_logging((b/":")[1..]*":");
+
+ DW(sprintf("parse_logformat : %O",log_format));
}
private int is_log_local() { return QUERY(LogLocal); };
@@ -134,9 +136,9 @@
{
defvar("LogFormat",
- "$virtname 404: $host $referer - [$cern_date] \"$method $resource
$protocol\" 404 - $virtname\n"
- "$virtname 500: $host ERROR - [$cern_date] \"$method $resource $protocol\"
500 - $virtname\n"
- "$virtname *: $host - - [$cern_date] \"$method $resource $protocol\"
$response $length $virtname"
+ "404: $ip_number $referer - [$cern_date] \"$method $resource $protocol\"
404 - $virtname\n"
+ "500: $ip_number ERROR - [$cern_date] \"$method $resource $protocol\" 500 -
$virtname\n"
+ "*: $ip_number - - [$cern_date] \"$method $resource $protocol\" $response
$length $virtname"
,
"Logging Format",
@@ -153,7 +155,6 @@
"$wchar(int) -- Insert the (2 byte) word specified by the
integer.<br />"
"$int(int) -- Insert the (4 byte) word specified by the
integer.<br />"
"$^ -- Supress newline at the end of the logentry<br />"
- "$host -- The remote host name, or ip number.<br />"
"$ip_number -- The remote ip number.<br />"
"$bin-ip_number -- The remote host id as a binary integer number.<br
/>"
"<br />"
@@ -194,6 +195,8 @@
"When syslog is used, this will be the identification of the "
"Caudium daemon. The entered value will be appended to all logs.",
1, is_log_local);
+ defvar("Insert","1","Insert VHS name", TYPE_FLAG,
+ "Insert VHS hostname at the begining of the line (before 200, or
whatever");
}
int loggingfield; // Set the stuff for logginf
@@ -223,6 +226,7 @@
if(QUERY(LogSP))
loggingfield = loggingfield | LOG_PID;
+ DW(sprintf("loggingfield -> : %x",loggingfield));
}
void localsyslog (string data)
@@ -230,6 +234,7 @@
// This is heavy stuff... we open and close syslog everytime
// but this is need because we don't want blocking IO.
+ DW(sprintf("Local : %s",data));
// openlog(QUERY(LogNA), loggingfield);
syslog(loggingfield, data);
// closelog();
@@ -238,6 +243,7 @@
void hostsyslog(string data)
{
// more simple... :p
+ DW(sprintf("Remote : %s",data));
Protocols.Syslog.remote(loggingfield, data, QUERY(LogHost));
}
@@ -249,6 +255,8 @@
if (!(form=log_format[(string)file->error]))
form = log_format["*"];
+
+ DW(sprintf("To log (1)-> : %O",form));
if(!form) return;
@@ -280,10 +288,9 @@
(string)request_id->misc->host,
}) );
- if(search(form, "host") != -1)
- caudium->ip_to_host(request_id->remoteaddr, write_to_log, form,
- request_id->host||request_id->remoteaddr, log_function);
- else
+ DW(sprintf("To log (2)-> : %O",form));
+ if(QUERY(Insert))
+ form = (string)request_id->misc->host + " " + form;
log_function(form);
}
@@ -301,12 +308,9 @@
mixed log(object id, mapping file)
{
- string s;
- object fnord;
-
if (!id->misc->vhs || !id->misc->vhs->logpath) return 0;
- DW(sprintf("[VHLog] file = %s", s || "???"));
+ DW("Logging engaged.");
if(QUERY(LogLocal))
do_log(file, id, localsyslog);
@@ -317,3 +321,56 @@
+
+/* START AUTOGENERATED DEFVAR DOCS */
+
+//! defvar: LogFormat
+//! What format to use for logging. The syntax is:
+//!<pre>response-code or *: Log format for that response acode<br /><br
/>Log format is normal characters, or one or more of the variables below:<br
/><br />\n \t \r -- As in C, newline, tab and linefeed<br />$char(int)
-- Insert the (1 byte) character specified by the integer.<br
/>$wchar(int) -- Insert the (2 byte) word specified by the integer.<br
/>$int(int) -- Insert the (4 byte) word specified by the integer.<br
/>$^ -- Supress newline at the end of the logentry<br
/>$ip_number -- The remote ip number.<br />$bin-ip_number -- The remote
host id as a binary integer number.<br /><br />$cern_date -- Cern Common
Log file format date.<br />$bin-date -- Time, but as an 32 bit iteger in
network byteorder<br /><br />$method -- Request method<br />$resource
-- Resource identifier<br />$protocol -- The protocol used (normally
HTTP/1.0)<br />$response -- The response code sent<br />$bin-response
-- The response code
sent as a binary short number<br />$length -- The length of the data
section of the reply<br />$bin-length -- Same, but as an 32 bit iteger in
network byteorder<br />$referer -- the header 'referer' from the
request, or '-'.<br />$user_agent -- the header 'User-Agent' from the
request, or '-'.<br />$agent_unquoted -- the header 'User-Agent' from the
request, or '-'.<br /><br />$user -- the name of the auth user used,
if any<br />$user_id -- A unique user ID, if cookies are supported,<br
/> by the client, otherwise '0'<br />$virtname --
virtual host name<br /></pre>
+//! type: TYPE_TEXT_FIELD
+//! name: Logging Format
+//
+//! defvar: LogLocal
+//! If set, the syslogger module will log on local machine
+//! type: TYPE_FLAG
+//! name: Log to local syslog ?
+//
+//! defvar: LogHost
+//! Hostname or IP to use to log using Syslog UDP protocol
+//! type: TYPE_STRING
+//! name: Host to log to
+//
+//! defvar: LogSP
+//! If set, the PID will be included in the syslog.
+//! type: TYPE_FLAG
+//! name: Log PID
+//
+//! defvar: LogST
+//! Which log type should be used.
+//! type: TYPE_STRING_LIST
+//! name: Log type
+//
+//! defvar: LogNA
+//! When syslog is used, this will be the identification of the Caudium
daemon. The entered value will be appended to all logs.
+//! type: TYPE_STRING
+//! name: Log as
+//
+//! defvar: Insert
+//! Insert VHS hostname at the begining of the line (before 200, or whatever
+//! type: TYPE_FLAG
+//! name: Insert VHS name
+//
+
+/*
+ * If you visit a file that doesn't contain these lines at its end, please
+ * cut and paste everything from here to that file.
+ */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 2
+ * End:
+ *
+ * vim: softtabstop=2 tabstop=2 expandtab autoindent formatoptions=croqlt
smartindent cindent shiftwidth=2
+ */
+
- CVS: caudium/server/modules/vhs vhs_syslogger.pike,1.1.2.1,1.1.2.2, Xavier Beaudouin
Archive powered by MhonArc 2.6.10.