HomeClusterLabs Projects

Refactor: libcrmcommon: Use message functions for XML patchsets

Description

Refactor: libcrmcommon: Use message functions for XML patchsets

Log and default are basically the same. Log allows early return based on
what logging is enabled. It also sets an option conditionally upon the
log level, which makes duplicating a bit of code in the message
functions cleaner than trying to functionize more of the common parts.

This commit adds support for the XML output format. The formatting
options that we've always used don't make sense for XML output, so we
simply add a copy of the XML to the output in a CDATA block.

An alternative would be to output the XML as-is, perhaps as the child of
a "patchset" wrapper element, and allow pcmk__output_t:finish() to call
dump_xml_formatted_with_text() instead of doing it ourselves. Then a
schema could either simply accept any element in that position, or
validate the specific structure since the structure is fully under
Pacemaker's control.

There is an unfortunately large amount of work needed on the caller side
to prepare the callers to use the new message function version of
pcmkxml_log_patchset(). Several callers now have to create ad-hoc
pcmk
output_t objects for the call. Each daemon reuses a single object,
but the libraries create them ad hoc. It's unclear whether it's worth
the hassle of maintaining a library-global scope or file-scope logger
object, and devising a way to free it before program exit, for each
case. Especially since crm_exit() can't free objects in libcib.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Feb 8 2023, 11:56 PM
Parents
rP6b9e87802161: Refactor: based: Make logger_out object global
Branches
Unknown
Tags
Unknown