# Templates for local and remote logging
$template DynLocalSquid, "/var/log/rsyslog/local/squid/squid%syslogfacility-text:6:$:%.%syslogseverity-text%.log"
$template DynRemoteSquid, "/var/log/rsyslog/remote/%fromhost%/squid/squid%syslogfacility:6:$:%.%syslogseverity-text%.log"

%if %%activer_log_distant == 'oui' and %%activer_reception_logs == 'non'
# all messages go in local branch
:programname, contains, "squid" ?DynLocalSquid
& stop
%else
# all messages from localhost go in local branch
if $programname contains 'squid' and $fromhost-ip startswith '127' then ?DynLocalSquid
& stop
%if %%mode_conteneur_actif == 'oui'
# all messages from containers go in local branch
if $programname contains 'squid' and $fromhost-ip startswith '%%adresse_ip_br0[:-2]' then ?DynLocalSquid
& stop
if $programname contains 'squid' and $fromhost startswith '%%adresse_ip_br0[:-2]' then ?DynLocalSquid
& stop
%end if
# all remaining messages go in remote branch
:programname, contains, "squid" ?DynRemoteSquid
& stop
%end if
