[syslog-ng] is it possible to use if() ... else statements on syslog-ng 3.7?

Evan Rempel erempel at uvic.ca
Thu May 11 05:34:19 UTC 2017


The 3.9 docs show a padding function

$(padding <macro> <prepended characters>)

but the examples show a length argument

$(padding $MESSAGE 10 X): bar
would produce a result of XXXXXXXbar

but that is unclear. Where does $MESSAGE go? Does $MESSAGE get populated 
with XXXXXXXbar


So maybe it could be written

$(padding $min_slice 2 "0"): $(* $(/ $R_MIN 5) 5)


There is some way to do it, but I can't figure it out from the docs.

Evan.


On 05/10/2017 09:39 PM, Scheidler, Bal√°zs wrote:
> Yes, you can also combine the first two:
>
> $(* $(/ $R_MIN 5) 5)
>
> It would be nice to have a template function that does the padding, 
> but right now we dont have that. In that case it could be like this:
>
> $(str-pad --width 2 --right --pad 0 $(* $(/ $R_MIN 5) 5))
>
> Or something like that. A specialized template function that does 
> exactly this could also br useful:
>
> $(slice $R_MIN 5)
>
> Although the naming can be tricky (I don't think slice conveys the 
> meaning well enough).
>
> Creating a simple template function is not too difficult, just look at 
> the basicfuncs module.
>
> One with arguments is more difficult though.
>
> Bazsi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20170510/4df5fd6e/attachment-0001.html>


More information about the syslog-ng mailing list