@@ -1067,6 +1067,27 @@ end}.
10671067{mapping, "log.syslog", "rabbit.log.syslog.enabled", [
10681068 {datatype, {enum, [true, false]}}
10691069]}.
1070+
1071+ {translation, "rabbit.log.syslog.enabled",
1072+ fun(Conf) ->
1073+ case cuttlefish:conf_get("log.syslog", Conf) of
1074+ true ->
1075+ case cuttlefish:conf_get("log.syslog.ip", Conf, undefined) of
1076+ undefined ->
1077+ case cuttlefish:conf_get("log.syslog.host", Conf, undefined) of
1078+ undefined ->
1079+ cuttlefish:invalid("Either log.syslog.ip or log.syslog.host must be set");
1080+ _Host ->
1081+ true
1082+ end;
1083+ _IpAddr ->
1084+ true
1085+ end;
1086+ _ ->
1087+ []
1088+ end
1089+ end}.
1090+
10701091{mapping, "log.syslog.level", "rabbit.log.syslog.level", [
10711092 {datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
10721093]}.
@@ -1086,10 +1107,31 @@ end}.
10861107 {datatype, {enum, [true, false]}}
10871108]}.
10881109
1110+ {mapping, "log.syslog.ip", "syslog.dest_host", [
1111+ {datatype, string},
1112+ {validators, ["is_ip"]}
1113+ ]}.
1114+
10891115{mapping, "log.syslog.host", "syslog.dest_host", [
10901116 {datatype, string}
10911117]}.
10921118
1119+ {translation, "syslog.dest_host",
1120+ fun(Conf) ->
1121+ case cuttlefish:conf_get("log.syslog", Conf) of
1122+ true ->
1123+ case cuttlefish:conf_get("log.syslog.ip", Conf, undefined) of
1124+ undefined ->
1125+ % If log.syslog.ip is not set, then this must be set
1126+ cuttlefish:conf_get("log.syslog.host", Conf);
1127+ IpAddr ->
1128+ IpAddr
1129+ end;
1130+ _ ->
1131+ cuttlefish:invalid("log.syslog must be set to true to set log.syslog.host or log.syslog.ip")
1132+ end
1133+ end}.
1134+
10931135{mapping, "log.syslog.port", "syslog.dest_port", [
10941136 {datatype, integer}
10951137]}.
@@ -1352,6 +1394,12 @@ fun(File) ->
13521394 element(1, ReadFile) == ok
13531395end}.
13541396
1397+ {validator, "is_ip", "string is a valid IP address",
1398+ fun(IpStr) ->
1399+ Res = inet:parse_address(IpStr),
1400+ element(1, Res) == ok
1401+ end}.
1402+
13551403{validator, "non_negative_integer", "number should be greater or equal to zero",
13561404fun(Int) when is_integer(Int) ->
13571405 Int >= 0
0 commit comments