You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Rodent of Unusual Size <co...@hyperreal.org> on 1997/09/12 16:50:55 UTC
cvs commit: apachen/src/modules/standard mod_log_config.c
coar 97/09/12 07:50:54
Modified: htdocs/manual/mod mod_log_config.html
src CHANGES
src/modules/standard mod_log_config.c
Log:
Changes to mod_log_config to allow naming of format strings.
Format nicknames are defined with "LogFormat fmt nickname", and can
be used with "LogFormat nickname" and "CustomLog logtarget nickname".
Revision Changes Path
1.19 +65 -18 apachen/htdocs/manual/mod/mod_log_config.html
Index: mod_log_config.html
===================================================================
RCS file: /export/home/cvs/apachen/htdocs/manual/mod/mod_log_config.html,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- mod_log_config.html 1997/06/04 16:14:22 1.18
+++ mod_log_config.html 1997/09/12 14:50:47 1.19
@@ -203,36 +203,79 @@
href="mod_cookies.html">mod_cookies</a>, and is deprecated.
<p>
+<HR>
<H2><A NAME="customlog">CustomLog</A></H2>
-<STRONG>Syntax:</STRONG> CustomLog <em>file-pipe</em> <em>format</em><BR>
+<STRONG>Syntax:</STRONG> CustomLog <em>file-pipe</em>
+ <em>format-or-nickname</em><BR>
<STRONG>Context:</STRONG> server config, virtual host<BR>
<STRONG>Status:</STRONG> Base<BR>
-<STRONG>Module:</STRONG> mod_log_config<P>
-
-The first argument is the filename to log to. This is used
-exactly like the argument to <tt>TransferLog</tt>, that is,
-it is either a full path, or relative to the current
-server root. <p>
-
+<STRONG>Compatibility: </STRONG> Nickname only available in Apache 1.3
+ or later
+<BR>
+<STRONG>Module:</STRONG> mod_log_config
+<P>
+The first argument is the filename to which log records should be
+written. This is used
+exactly like the argument to
+<A
+ HREF="#transferlog"
+><SAMP>TransferLog</SAMP></A>;
+that is, it is either a full path or relative to the current
+server root.
+</P>
+<P>
The format argument specifies a format for each line of the log file.
The options available for the format are exactly the same as for
the argument of the <tt>LogFormat</tt> directive. If the format
includes any spaces (which it will do in almost all cases) it
should be enclosed in double quotes.
-
+</P>
+<P>
+Instead of an actual format string, you can use a format nickname defined with
+the
+<A
+ HREF="#logformat"
+><SAMP>LogFormat</SAMP></A>
+directive.
+</P>
+<HR>
<h2><A name="logformat">LogFormat</A></h2>
<!--%plaintext <?INDEX {\tt LogFormat} directive> -->
-<strong>Syntax:</strong> LogFormat <em>string</em><br>
+<strong>Syntax:</strong> LogFormat <em>format</em> [<EM>nickname</EM>]
+<br>
<strong>Default:</strong> <code>LogFormat "%h %l %u %t \"%r\"
%s %b"</code><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Base<br>
-<strong>Module:</strong> mod_log_config<p>
-
-This sets the format of the logfile. See <A HREF="#formats">
-Custom Log Formats</A> for details on the format arguments.<p><hr>
-
+<STRONG>Compatibility: </STRONG> Nickname only available in Apache 1.3
+ or later
+<BR>
+<strong>Module:</strong> mod_log_config
+<P>
+This sets the format of the default logfile named by the
+<A
+ HREF="#transferlog"
+><SAMP>TransferLog</SAMP></A>
+directive . See the section on
+<A HREF="#formats">Custom Log Formats</A> for details on the format
+arguments.
+</P>
+<P>
+If you include a nickname for the format on the directive line, you can
+use it in other <SAMP>LogFormat</SAMP> and
+<A
+ HREF="#customlog"
+><SAMP>CustomLog</SAMP></A>
+directives rather than repeating the entire format string.
+</P>
+<P>
+A
+<SAMP>LogFormat</SAMP> directive which defines a nickname <STRONG>does
+nothing else</STRONG> -- that is, it <EM>only</EM> defines the nickname,
+it doesn't actually apply the format and make it the default.
+</P>
+<hr>
<h2><A name="transferlog">TransferLog</A></h2>
<!--%plaintext <?INDEX {\tt TransferLog} directive> -->
<strong>Syntax:</strong> TransferLog <em>file-pipe</em><br>
@@ -241,7 +284,13 @@
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_log_config<p>
-The TransferLog directive adds a log file in Common Log Format.
+The TransferLog directive adds a log file in the format defined by the
+most recent
+<A
+ HREF="#logformat"
+><SAMP>LogFormat</SAMP></A>
+directive, or Common Log Format if no other default format has been
+specified.
<em>File-pipe</em> is one
of
<dl><dt>A filename
@@ -259,5 +308,3 @@
<!--#include virtual="footer.html" -->
</BODY>
</HTML>
-
-
1.434 +5 -0 apachen/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apachen/src/CHANGES,v
retrieving revision 1.433
retrieving revision 1.434
diff -u -r1.433 -r1.434
--- CHANGES 1997/09/11 20:49:54 1.433
+++ CHANGES 1997/09/12 14:50:50 1.434
@@ -1,5 +1,10 @@
Changes with Apache 1.3b1
+ *) Changes to mod_log_config to allow naming of format strings.
+ Format nicknames are defined with "LogFormat fmt nickname", and can
+ be used with "LogFormat nickname" and "CustomLog logtarget nickname".
+ [Ken Coar]
+
*) New module, "mod_speling", which can help find files even when
the URL is slightly misspelled. [Martin Kraemer, Alexei Kosut]
1.37 +50 -13 apachen/src/modules/standard/mod_log_config.c
Index: mod_log_config.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_log_config.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- mod_log_config.c 1997/08/23 02:59:45 1.36
+++ mod_log_config.c 1997/09/12 14:50:53 1.37
@@ -195,6 +195,7 @@
array_header *default_format;
array_header *config_logs;
array_header *server_config_logs;
+ table *formats;
} multi_log_state;
/*
@@ -609,13 +610,16 @@
make_array(p, 5, sizeof (config_log_state));
mls->default_format = NULL;
mls->server_config_logs = NULL;
+ mls->formats = make_table(p, 4);
+ table_set(mls->formats, "CLF", DEFAULT_LOG_FORMAT);
return mls;
}
/*
* Use the merger to simply add a pointer from the vhost log state
- * to the log of logs specified for the non-vhost configuration
+ * to the log of logs specified for the non-vhost configuration. Make sure
+ * vhosts inherit any globally-defined format names.
*/
static void *merge_config_log_state (pool *p, void *basev, void *addv)
@@ -624,35 +628,68 @@
multi_log_state *add = (multi_log_state *)addv;
add->server_config_logs = base->config_logs;
- if (!add->default_format)
+ if (!add->default_format) {
add->default_format = base->default_format;
+ }
+ add->formats = overlay_tables(p, base->formats, add->formats);
return add;
}
-static const char *log_format (cmd_parms *cmd, void *dummy, char *arg)
+/*
+ * Set the default logfile format, or define a nickname for a format string.
+ */
+static const char *log_format (cmd_parms *cmd, void *dummy, char *fmt,
+ char *name)
{
const char *err_string = NULL;
+ char *format;
multi_log_state *mls = get_module_config (cmd->server->module_config,
- &config_log_module);
-
- mls->default_format = parse_log_string (cmd->pool, arg, &err_string);
+ &config_log_module);
+
+ /*
+ * If we were given two arguments, the second is a name to be given to the
+ * format. This syntax just defines the nickname - it doesn't actually
+ * make the format the default.
+ */
+ if (name != NULL) {
+ parse_log_string(cmd->pool, fmt, &err_string);
+ if (err_string == NULL) {
+ table_set(mls->formats, name, fmt);
+ }
+ }
+ else {
+ /*
+ * See if we were given a name rather than a format string.
+ */
+ format = table_get(mls->formats, fmt);
+ if (format == NULL) {
+ format = fmt;
+ }
+ mls->default_format = parse_log_string (cmd->pool, format, &err_string);
+ }
return err_string;
}
-static const char *add_custom_log(cmd_parms *cmd, void *dummy, char *fn, char *fmt)
+static const char *add_custom_log(cmd_parms *cmd, void *dummy, char *fn,
+ char *fmt)
{
const char *err_string = NULL;
multi_log_state *mls = get_module_config (cmd->server->module_config,
&config_log_module);
config_log_state *cls;
+ char *format;
cls = (config_log_state*)push_array(mls->config_logs);
cls->fname = fn;
- if (!fmt)
+ if (!fmt) {
cls->format = NULL;
- else
- cls->format = parse_log_string (cmd->pool, fmt, &err_string);
+ }
+ else {
+ format = table_get(mls->formats, fmt);
+ format = (format != NULL) ? format : fmt;
+ cls->format = parse_log_string (cmd->pool, format, &err_string);
+ }
cls->log_fd = -1;
return err_string;
@@ -670,11 +707,11 @@
static command_rec config_log_cmds[] = {
{ "CustomLog", add_custom_log, NULL, RSRC_CONF, TAKE2,
- "a file name and a custom log format string" },
+ "a file name and a custom log format string or format name" },
{ "TransferLog", set_transfer_log, NULL, RSRC_CONF, TAKE1,
"the filename of the access log" },
-{ "LogFormat", log_format, NULL, RSRC_CONF, TAKE1,
- "a log format string (see docs)" },
+{ "LogFormat", log_format, NULL, RSRC_CONF, TAKE12,
+ "a log format string (see docs) and an optional format name" },
{ "CookieLog", set_cookie_log, NULL, RSRC_CONF, TAKE1,
"the filename of the cookie log" },
{ NULL }