def format_exc_for_journald(ex, indent_lines=False):
    """
    Journald removes leading whitespace from every line, making it very
    hard to read python traceback messages. This tricks journald into
    not removing leading whitespace by adding a dot at the beginning of
    every line
    :param ex: Error lines
    :param indent_lines: If indentation of lines should be present or not
    :type indent_lines: bool
    """
    result = ''
    for line in ex.splitlines():
        if indent_lines:
            result += ".    " + line + "\n"
        else:
            result += "." + line + "\n"
    return result.rstrip()