--- /dev/null
+*** Settings ***
+Suite Setup Rspamd Setup
+Suite Teardown Systemd Teardown
+Library ${RSPAMD_TESTDIR}/lib/rspamd.py
+Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
+Variables ${RSPAMD_TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG} ${RSPAMD_TESTDIR}/configs/loggingtest.conf
+${RSPAMD_LOGGINGTYPE} console
+${RSPAMD_JSON} false
+${RSPAMD_SYSTEMD} true
+${RSPAMD_SCOPE} Suite
+
+*** Test Cases ***
+EMPTY TEST
+ Pass Execution No worries
+
+*** Keywords ***
+Systemd Teardown
+ Touch ${RSPAMD_TMPDIR}/rspamd.log
+ Rspamd Teardown
+ ${log} = Get File ${EXECDIR}/robot-save/rspamd.stderr.last
+ Should Match Regexp ${log} \\n\\(main\\) lua; lua_cfg_transform\\.lua:\\d+: overriding actions from the legacy metric settings\\n
--- /dev/null
+*** Settings ***
+Suite Setup Rspamd Setup
+Suite Teardown Console Timestamps Teardown
+Library ${RSPAMD_TESTDIR}/lib/rspamd.py
+Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
+Variables ${RSPAMD_TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG} ${RSPAMD_TESTDIR}/configs/loggingtest.conf
+${RSPAMD_LOGGINGTYPE} console
+${RSPAMD_JSON} false
+${RSPAMD_SYSTEMD} false
+${RSPAMD_SCOPE} Suite
+
+*** Test Cases ***
+EMPTY TEST
+ Pass Execution No worries
+
+*** Keywords ***
+Console Timestamps Teardown
+ Touch ${RSPAMD_TMPDIR}/rspamd.log
+ Rspamd Teardown
+ ${log} = Get File ${EXECDIR}/robot-save/rspamd.stderr.last
+ Should Match Regexp ${log} \\n\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} #\\d+\\(main\\) lua; lua_cfg_transform\\.lua:\\d+: overriding actions from the legacy metric settings\\n
--- /dev/null
+*** Settings ***
+Test Setup Rspamd Setup
+Library ${RSPAMD_TESTDIR}/lib/rspamd.py
+Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
+Variables ${RSPAMD_TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG} ${RSPAMD_TESTDIR}/configs/loggingtest.conf
+${RSPAMD_LOGGINGTYPE} file
+${RSPAMD_JSON} true
+${RSPAMD_SYSTEMD} true
+${RSPAMD_SCOPE} Test
+
+*** Test Cases ***
+JSON LOGS
+ Rspamd Teardown
+ Check JSON Log ${EXECDIR}/robot-save/rspamd.log.last
+++ /dev/null
-*** Settings ***
-Suite Setup Rspamd Setup
-Suite Teardown Systemd Teardown
-Library ${RSPAMD_TESTDIR}/lib/rspamd.py
-Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
-Variables ${RSPAMD_TESTDIR}/lib/vars.py
-
-*** Variables ***
-${CONFIG} ${RSPAMD_TESTDIR}/configs/systemd.conf
-${RSPAMD_SCOPE} Suite
-
-*** Test Cases ***
-EMPTY TEST
- Pass Execution No worries
-
-*** Keywords ***
-Systemd Teardown
- Touch ${RSPAMD_TMPDIR}/rspamd.log
- Rspamd Teardown
- ${log} = Get File ${EXECDIR}/robot-save/rspamd.stderr.last
- Should Match Regexp ${log} \\n\\(main\\) lua; lua_cfg_transform\\.lua:\\d+: overriding actions from the legacy metric settings\\n
--- /dev/null
+logging {
+ type = "{= env.LOGGINGTYPE =}";
+ json = {= env.JSON =};
+ systemd = {= env.SYSTEMD =};
+}
--- /dev/null
+.include(duplicate=append,priority=0) "{= env.TESTDIR =}/configs/trivial.conf"
+
+.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/loggingtest-local.conf"
+++ /dev/null
-logging {
- type = "console";
- systemd = true;
-}
+++ /dev/null
-.include(duplicate=append,priority=0) "{= env.TESTDIR =}/configs/trivial.conf"
-
-.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/systemd-local.conf"
assert 'error' not in d
return d
+def check_json_log(fn):
+ line_count = 0
+ f = open(fn, 'r')
+ for l in f.readlines():
+ d = demjson.decode(l, strict=True)
+ assert len(d) > 0
+ line_count = line_count + 1
+ assert line_count > 0
+
def cleanup_temporary_directory(directory):
shutil.rmtree(directory)