}
const char *
-NotePairs::find(const char *noteKey) const
+NotePairs::find(const char *noteKey, const char *sep) const
{
static String value;
value.clean();
for (Vector<NotePairs::Entry *>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
if ((*i)->name.cmp(noteKey) == 0) {
if (value.size())
- value.append(", ");
- value.append(ConfigParser::QuoteString((*i)->value));
+ value.append(sep);
+ value.append((*i)->value);
}
}
return value.size() ? value.termedBuf() : NULL;
for (Vector<NotePairs::Entry *>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
value.append((*i)->name);
value.append(": ");
- value.append(ConfigParser::QuoteString((*i)->value));
+ value.append((*i)->value);
value.append(sep);
}
return value.size() ? value.termedBuf() : NULL;
* Returns a comma separated list of notes with key 'noteKey'.
* Use findFirst instead when a unique kv-pair is needed.
*/
- const char *find(const char *noteKey) const;
+ const char *find(const char *noteKey, const char *sep = ",") const;
/**
* Returns the first note value for this key or an empty string.
err_code The ID of an error response served by Squid or
a similar internal error identifier.
err_detail Additional err_code-dependent error information.
- note The meta header specified by the argument. Also
+ note The annotation specified by the argument. Also
logs the adaptation meta headers set by the
adaptation_meta configuration parameter.
- If no argument given all meta headers logged.
+ If no argument given all annotations logged.
+ The argument may include a separator to use with
+ annotation values:
+ name[:separator]
+ By default, multiple note values are separated with ","
+ and multiple notes are separated with "\r\n".
+ When logging named notes with %{name}note, the
+ explicitly configured separator is used between note
+ values. When logging all notes with %note, the
+ explicitly configured separator is used between
+ individual notes. There is currently no way to
+ specify both value and notes separators when logging
+ all notes with %note.
Connection related format codes:
#endif
case LFT_NOTE:
- if (fmt->data.string) {
+ tmp[0] = fmt->data.header.separator;
+ tmp[1] = '\0';
+ if (fmt->data.header.header && *fmt->data.header.header) {
+ const char *separator = tmp;
#if USE_ADAPTATION
Adaptation::History::Pointer ah = al->request ? al->request->adaptHistory() : Adaptation::History::Pointer();
if (ah != NULL && ah->metaHeaders != NULL) {
- if (const char *meta = ah->metaHeaders->find(fmt->data.string))
+ if (const char *meta = ah->metaHeaders->find(fmt->data.header.header, separator))
sb.append(meta);
}
#endif
if (al->notes != NULL) {
- if (const char *note = al->notes->find(fmt->data.string)) {
+ if (const char *note = al->notes->find(fmt->data.header.header, separator)) {
if (sb.size())
- sb.append(", ");
+ sb.append(separator);
sb.append(note);
}
}
out = sb.termedBuf();
quote = 1;
} else {
+ // if no argument given use default "\r\n" as notes separator
+ const char *separator = fmt->data.string ? tmp : "\r\n";
#if USE_ADAPTATION
Adaptation::History::Pointer ah = al->request ? al->request->adaptHistory() : Adaptation::History::Pointer();
if (ah != NULL && ah->metaHeaders != NULL && !ah->metaHeaders->empty())
- sb.append(ah->metaHeaders->toString());
+ sb.append(ah->metaHeaders->toString(separator));
#endif
if (al->notes != NULL && !al->notes->empty())
- sb.append(al->notes->toString());
+ sb.append(al->notes->toString(separator));
out = sb.termedBuf();
quote = 1;
case LFT_REPLY_HEADER:
+ case LFT_NOTE:
+
if (data.string) {
char *header = data.string;
char *cp = strchr(header, ':');
return (cur - def);
}
+Format::Token::Token() : type(LFT_NONE),
+ label(NULL),
+ widthMin(-1),
+ widthMax(-1),
+ quote(LOG_QUOTE_NONE),
+ left(false),
+ space(false),
+ zero(false),
+ divisor(1),
+ next(NULL)
+{
+ data.string = NULL;
+ data.header.header = NULL;
+ data.header.element = NULL;
+ data.header.separator = ',';
+}
+
+
+
Format::Token::~Token()
{
label = NULL; // drop reference to global static.
class Token
{
public:
- Token() : type(LFT_NONE),
- label(NULL),
- widthMin(-1),
- widthMax(-1),
- quote(LOG_QUOTE_NONE),
- left(false),
- space(false),
- zero(false),
- divisor(1),
- next(NULL)
- { data.string = NULL; }
-
+ Token();
~Token();
/// Initialize the format token registrations
ByteCode_t type;
const char *label;
- union {
+ struct {
char *string;
struct {