21 typedef struct private_data_s {
29 const char *proc_stdout,
const char *proc_stderr) {
41 g_queue_free(priv->prefixes);
51 if (out->
priv != NULL) {
56 if (out->
priv == NULL) {
62 priv->prefixes = g_queue_new();
63 priv->log_level = LOG_INFO;
77 out->
dest = freopen(NULL,
"w", out->
dest);
92 do_crm_log(priv->log_level,
"Pacemaker %s (Build: %s): %s",
96 do_crm_log(priv->log_level,
"Written by Andrew Beekhof and" 97 "the Pacemaker project contributors");
110 va_start(ap, format);
114 len = vasprintf(&buffer, format, ap);
125 xmlNodePtr node = NULL;
139 log_begin_list(
pcmk__output_t *out, const
char *singular_noun, const
char *plural_noun,
140 const
char *format, ...) {
149 va_start(ap, format);
150 len = vasprintf(&buffer, format, ap);
157 if(strcmp(buffer,
"") == 0) {
161 g_queue_push_tail(priv->prefixes, buffer);
170 char prefix[LINE_MAX] = { 0 };
177 for (GList* gIter = priv->prefixes->head; gIter; gIter = gIter->next) {
178 if (strcmp(prefix,
"") != 0) {
179 offset += snprintf(prefix + offset, LINE_MAX - offset,
": %s", (
char *)gIter->data);
181 offset = snprintf(prefix, LINE_MAX,
"%s", (
char *)gIter->data);
185 va_start(ap, format);
186 len = vasprintf(&buffer, format, ap);
190 if (strcmp(buffer,
"") != 0) {
191 if ((
name != NULL) && (strcmp(
name,
"") != 0)) {
192 if (strcmp(prefix,
"") != 0) {
198 if (strcmp(prefix,
"") != 0) {
199 do_crm_log(priv->log_level,
"%s: %s", prefix, buffer);
215 if (priv->prefixes == NULL) {
220 free((
char *)priv->prefixes->tail->data);
221 g_queue_pop_tail(priv->prefixes);
235 va_start(ap, format);
236 len = vasprintf(&buffer, format, ap);
262 log_prompt(
const char *prompt,
bool echo,
char **dest) {
270 if (retval == NULL) {
275 retval->
request = argv == NULL ? NULL : g_strjoinv(
" ", argv);
277 retval->
init = log_init;
279 retval->
finish = log_finish;
280 retval->
reset = log_reset;
287 retval->
info = log_info;
288 retval->
err = log_err;
296 retval->
spacer = log_spacer;
298 retval->
prompt = log_prompt;
314 priv->log_level = log_level;
void(* end_list)(pcmk__output_t *out)
int(* message)(pcmk__output_t *out, const char *message_id,...)
const char * fmt_name
The name of this output formatter.
bool(* is_quiet)(pcmk__output_t *out)
void(* spacer)(pcmk__output_t *out)
void pcmk__register_message(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
enum crm_exit_e crm_exit_t
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define PACEMAKER_VERSION
int pcmk__call_message(pcmk__output_t *out, const char *message_id,...)
void(* prompt)(const char *prompt, bool echo, char **dest)
void * priv
Implementation-specific private data.
void(* register_message)(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
struct private_data_s private_data_t
#define do_crm_log(level, fmt, args...)
Log a message.
void(* free_priv)(pcmk__output_t *out)
bool(* init)(pcmk__output_t *out)
int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define do_crm_log_xml(level, text, xml)
Log XML line-by-line in a formatted fashion.
void pcmk__output_set_log_level(pcmk__output_t *out, int log_level)
GOptionEntry pcmk__log_output_entries[]
FILE * dest
Where output should be written.
const xmlChar * pcmkXmlStr
#define crm_err(fmt, args...)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
struct private_data_s private_data_t
gchar * request
A copy of the request that generated this output.
This structure contains everything that makes up a single output formatter.
void(* version)(pcmk__output_t *out, bool extended)
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
void(* reset)(pcmk__output_t *out)
void(* progress)(pcmk__output_t *out, bool end)
pcmk__output_t * pcmk__mk_log_output(char **argv)
void(* subprocess_output)(pcmk__output_t *out, int exit_status, const char *proc_stdout, const char *proc_stderr)