<commit_before>include_recipe "rs_utils::setup_logging"

ruby_block "Append OpenLDAP logging to RightScale syslog" do
  block do
    openldap_config = <<-EOF

# log slapd to a file and the RS syslog dashboard
destination d_ldap {
  file("/var/log/slapd");
  # Redirect from local4.debug to local1.notice because the RS syslog apparently doesn't like *.debug & just throws it away
  program("logger -p local1.notice" template("slapd \\$MSG\\n"));
};
# Match only local4 so we don't have an infinite loop of catching slapd messages on local1 and local4
filter f_ldap { facility(local4) and match(slapd); };
log { source(s_sys); filter(f_ldap); destination(d_ldap); };

    EOF
    ::File.open("/etc/syslog-ng/syslog-ng.conf", "a") {|f| f.write(openldap_config)}
  end
  notifies :restart, resources(:service => "syslog-ng")
end<commit_msg>Added a check for the syslog already being enabled<commit_after>include_recipe "rs_utils::setup_logging"

ruby_block "Append OpenLDAP logging to RightScale syslog" do
  block do
    openldap_config = <<-EOF

# log slapd to a file and the RS syslog dashboard
destination d_ldap {
  file("/var/log/slapd");
  # Redirect from local4.debug to local1.notice because the RS syslog apparently doesn't like *.debug & just throws it away
  program("logger -p local1.notice" template("slapd \\$MSG\\n"));
};
# Match only local4 so we don't have an infinite loop of catching slapd messages on local1 and local4
filter f_ldap { facility(local4) and match(slapd); };
log { source(s_sys); filter(f_ldap); destination(d_ldap); };

    EOF
    ::File.open("/etc/syslog-ng/syslog-ng.conf", "a") {|f| f.write(openldap_config)}
  end
  only_if `grep d_ldap /etc/syslog-ng/syslog-ng.conf` == ""
  notifies :restart, resources(:service => "syslog-ng")
end
{'fraction_non_alphanumeric': 0.12309429700734048, 'fraction_numerical': 0.007905138339920948, 'mean_word_length': 4.589905362776025, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6023654', 'n_tokens_mistral': 615, 'n_tokens_neox': 592, 'n_words': 185}