[syslog-ng]$DAY not working in filenames macros in 1.6.x as it did in 1.5.x

Balazs Scheidler syslog-ng@lists.balabit.hu
Thu, 03 Feb 2005 10:49:34 +0100


On Thu, 2005-02-03 at 12:30 +1100, Andrew Fort wrote:
> Andrew Fort wrote:
> 
> Oops - I knew I should've tried this before the original post.
> 

> I changed the file line to:
>      file("/var/log/LOCAL/$HOST/$YEAR/$MONTH/$YEAR$MONTH$DAY-$HOST-$PROGRAM"
> 
> And now I get what I am looking for,
> 
> e.g.
> 
> /var/log/LOCAL/mel1/2005/02/20050203-mel1-syslog-ng
> 
> So, what's special about the underscore? (i'd prefer to use an 
> underscore if I could... :).

The problem is the difference how macro expansion is performed in 1.5.x
and 1.6.x. This process has been signficantly enhanced performance wise,
so it first locates whole words in the template string (word characters
are [A-Z_], and once found it is replaced by the expansion value). The
'_' is taken part of the word and thus not a $DAY but a $DAY_ macro is
looked up which does not exist => becomes an empty value.

This is solved in the development branch by adding brace support to
expansion:

file("/var/log/LOCAL/$HOST/$YEAR/$MONTH/$YEAR$MONTH${DAY}_$HOST-$PROGRAM")

This makes it recognize the DAY macro and still add an underscore after
that. However I'd prefer not touching 1.6.x too much until 1.9.x becomes
2.0.0.

-- 
Bazsi