syslog-ng: Refactor configuration generation logic.

The old method was hard to maintain, so this commit introduces a more clean solution.
The commit also contains documentation fixes and new testcases.