root/lib/pacemaker/pcmk_output_utils.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcmk__out_prologue
  2. pcmk__out_epilogue
  3. pcmk__new_logger

   1 /*
   2  * Copyright 2019-2021 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 #include <crm/common/results.h>
  12 #include <crm/common/output_internal.h>
  13 #include <libxml/tree.h>
  14 #include <pacemaker-internal.h>
  15 
  16 pcmk__supported_format_t pcmk__out_formats[] = {
  17     PCMK__SUPPORTED_FORMAT_XML,
  18     { NULL, NULL, NULL }
  19 };
  20 
  21 int
  22 pcmk__out_prologue(pcmk__output_t **out, xmlNodePtr *xml) {
     /* [previous][next][first][last][top][bottom][index][help] */
  23     int rc = pcmk_rc_ok;
  24 
  25     if (*xml != NULL) {
  26         xmlFreeNode(*xml);
  27     }
  28 
  29     pcmk__register_formats(NULL, pcmk__out_formats);
  30     rc = pcmk__output_new(out, "xml", NULL, NULL);
  31     if (rc != pcmk_rc_ok) {
  32         return rc;
  33     }
  34 
  35     return rc;
  36 }
  37 
  38 void
  39 pcmk__out_epilogue(pcmk__output_t *out, xmlNodePtr *xml, int retval) {
     /* [previous][next][first][last][top][bottom][index][help] */
  40     if (retval == pcmk_rc_ok) {
  41         out->finish(out, 0, FALSE, (void **) xml);
  42     }
  43 
  44     pcmk__output_free(out);
  45 }
  46 
  47 /*!
  48  * \internal
  49  * \brief Create a new output object using the "log" format
  50  *
  51  * Create a new output object using the "log" format, and register the
  52  * libpe_status and libpacemaker messages.
  53  *
  54  * \return Newly created output object, or NULL on error
  55  */
  56 pcmk__output_t *
  57 pcmk__new_logger(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  58 {
  59     int rc = pcmk_rc_ok;
  60     pcmk__output_t *out = NULL;
  61     const char* argv[] = { "", NULL };
  62     pcmk__supported_format_t formats[] = {
  63         PCMK__SUPPORTED_FORMAT_LOG,
  64         { NULL, NULL, NULL }
  65     };
  66 
  67     pcmk__register_formats(NULL, formats);
  68     rc = pcmk__output_new(&out, "log", NULL, (char**)argv);
  69     if ((rc != pcmk_rc_ok) || (out == NULL)) {
  70         crm_err("Can't log resource details due to internal error: %s",
  71                 pcmk_rc_str(rc));
  72         return NULL;
  73     }
  74 
  75     pe__register_messages(out);
  76     pcmk__register_lib_messages(out);
  77     return out;
  78 }
  79 

/* [previous][next][first][last][top][bottom][index][help] */