Unlike in the "Final results", the effect of tags is taken into account.
-const char actions_rcs[] = "$Id: actions.c,v 1.82 2012/06/08 15:09:06 fabiankeil Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.83 2012/06/08 15:15:11 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
}
return result;
}
+
+
+/*********************************************************************
+ *
+ * Function : action_to_line_of_text
+ *
+ * Description : Converts a action spec to a single text line
+ * listing the enabled actions.
+ *
+ * Parameters :
+ * 1 : action = Current action spec to be converted
+ *
+ * Returns : A string. Caller must free it.
+ * Out-of-memory errors are fatal.
+ *
+ *********************************************************************/
+char *actions_to_line_of_text(const struct current_action_spec *action)
+{
+ char buffer[200];
+ struct list_entry *lst;
+ char *active;
+ const unsigned long flags = action->flags;
+
+ active = strdup_or_die("");
+
+#define DEFINE_ACTION_BOOL(__name, __bit) \
+ if (flags & __bit) \
+ { \
+ snprintf(buffer, sizeof(buffer), "+%s ", __name); \
+ string_append(&active, buffer); \
+ } \
+
+#define DEFINE_ACTION_STRING(__name, __bit, __index) \
+ if (flags & __bit) \
+ { \
+ snprintf(buffer, sizeof(buffer), "+%s{%s} ", \
+ __name, action->string[__index]); \
+ string_append(&active, buffer); \
+ } \
+
+#define DEFINE_ACTION_MULTI(__name, __index) \
+ lst = action->multi[__index]->first; \
+ while (lst != NULL) \
+ { \
+ snprintf(buffer, sizeof(buffer), "+%s{%s} ", \
+ __name, lst->str); \
+ string_append(&active, buffer); \
+ lst = lst->next; \
+ } \
+
+#define DEFINE_ACTION_ALIAS 0 /* No aliases for output */
+
+#include "actionlist.h"
+
+#undef DEFINE_ACTION_MULTI
+#undef DEFINE_ACTION_STRING
+#undef DEFINE_ACTION_BOOL
+#undef DEFINE_ACTION_ALIAS
+
+ if (active == NULL)
+ {
+ log_error(LOG_LEVEL_FATAL, "Out of memory in action_to_line_of_text()");
+ }
+
+ return active;
+}
#ifndef ACTIONS_H_INCLUDED
#define ACTIONS_H_INCLUDED
-#define ACTIONS_H_VERSION "$Id: actions.h,v 1.19 2009/05/16 13:27:20 fabiankeil Exp $"
+#define ACTIONS_H_VERSION "$Id: actions.h,v 1.20 2011/09/04 11:10:56 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.h,v $
const struct action_spec *src);
extern char * current_action_to_html(const struct client_state *csp,
const struct current_action_spec *action);
+extern char * actions_to_line_of_text(const struct current_action_spec *action);
extern jb_err get_action_token(char **line, char **name, char **value);
extern void unload_actions_file(void *file_data);
-const char errlog_rcs[] = "$Id: errlog.c,v 1.114 2012/03/09 17:55:50 fabiankeil Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.115 2012/07/27 17:27:47 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
case LOG_LEVEL_CGI:
log_level_string = "CGI";
break;
+ case LOG_LEVEL_ACTIONS:
+ log_level_string = "Actions";
+ break;
default:
log_level_string = "Unknown log level";
break;
#ifndef ERRLOG_H_INCLUDED
#define ERRLOG_H_INCLUDED
-#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.27 2011/09/04 11:10:56 fabiankeil Exp $"
+#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.28 2012/07/27 17:27:47 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.h,v $
#define LOG_LEVEL_CRUNCH 0x0400
#define LOG_LEVEL_CGI 0x0800 /* CGI / templates */
#define LOG_LEVEL_RECEIVED 0x8000
+#define LOG_LEVEL_ACTIONS 0x10000
/* Following are always on: */
#define LOG_LEVEL_INFO 0x1000
-const char jcc_rcs[] = "$Id: jcc.c,v 1.383 2012/07/23 12:55:25 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.384 2012/07/27 17:31:10 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
}
+/*********************************************************************
+ *
+ * Function : log_applied_actions
+ *
+ * Description : Logs the applied actions if LOG_LEVEL_ACTIONS is
+ * enabled.
+ *
+ * Parameters :
+ * 1 : actions = Current action spec to log
+ *
+ * Returns : Nothing.
+ *
+ *********************************************************************/
+static void log_applied_actions(const struct current_action_spec *actions)
+{
+ /*
+ * The conversion to text requires lots of memory allocations so
+ * we only do the conversion if the user is actually interested.
+ */
+ if (debug_level_is_enabled(LOG_LEVEL_ACTIONS))
+ {
+ char *actions_as_text = actions_to_line_of_text(actions);
+ log_error(LOG_LEVEL_ACTIONS, "%s", actions_as_text);
+ freez(actions_as_text);
+ }
+}
+
+
/*********************************************************************
*
* Function : send_crunch_response
status_code[3] = '\0';
/* Log that the request was crunched and why. */
+ log_applied_actions(csp->action);
log_error(LOG_LEVEL_CRUNCH, "%s: %s", crunch_reason(rsp), http->url);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" %s %u",
csp->ip_addr_str, http->ocmd, status_code, rsp->content_length);
return;
}
+ log_applied_actions(csp->action);
log_error(LOG_LEVEL_GPC, "%s%s", http->hostport, http->path);
if (fwd->forward_host)