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");
109 va_start(ap, format);
113 len = vasprintf(&buffer, format, ap);
124 xmlNodePtr node = NULL;
138 log_begin_list(
pcmk__output_t *out, const
char *singular_noun, const
char *plural_noun,
139 const
char *format, ...) {
148 va_start(ap, format);
149 len = vasprintf(&buffer, format, ap);
156 if(strcmp(buffer,
"") == 0) {
160 g_queue_push_tail(priv->prefixes, buffer);
165 log_list_item(
pcmk__output_t *out, const
char *name, const
char *format, ...) {
169 char prefix[LINE_MAX] = { 0 };
176 for (GList* gIter = priv->prefixes->head; gIter; gIter = gIter->next) {
177 if (strcmp(prefix,
"") != 0) {
178 offset += snprintf(prefix + offset, LINE_MAX - offset,
": %s", (
char *)gIter->data);
180 offset = snprintf(prefix, LINE_MAX,
"%s", (
char *)gIter->data);
184 va_start(ap, format);
185 len = vasprintf(&buffer, format, ap);
189 if (strcmp(buffer,
"") != 0) {
190 if ((name != NULL) && (strcmp(name,
"") != 0)) {
191 if (strcmp(prefix,
"") != 0) {
192 do_crm_log(priv->log_level,
"%s: %s: %s", prefix, name, buffer);
194 do_crm_log(priv->log_level,
"%s: %s", name, buffer);
197 if (strcmp(prefix,
"") != 0) {
198 do_crm_log(priv->log_level,
"%s: %s", prefix, buffer);
214 if (priv->prefixes == NULL) {
219 free((
char *)priv->prefixes->tail->data);
220 g_queue_pop_tail(priv->prefixes);
234 va_start(ap, format);
235 len = vasprintf(&buffer, format, ap);
261 log_prompt(
const char *prompt,
bool echo,
char **dest) {
269 if (retval == NULL) {
274 retval->
request = argv == NULL ? NULL : g_strjoinv(
" ", argv);
276 retval->
init = log_init;
278 retval->
finish = log_finish;
279 retval->
reset = log_reset;
286 retval->
info = log_info;
287 retval->
err = log_err;
295 retval->
spacer = log_spacer;
297 retval->
prompt = log_prompt;
313 priv->log_level = log_level;
bool(* init)(pcmk__output_t *out)
void pcmk__output_set_log_level(pcmk__output_t *out, int log_level)
void(* register_message)(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
const char * fmt_name
The name of this output formatter.
void(* reset)(pcmk__output_t *out)
void pcmk__register_message(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
int(* message)(pcmk__output_t *out, const char *message_id,...)
enum crm_exit_e crm_exit_t
int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define PACEMAKER_VERSION
pcmk__output_t * pcmk__mk_log_output(char **argv)
int pcmk__call_message(pcmk__output_t *out, const char *message_id,...)
void * priv
Implementation-specific private data.
bool(* is_quiet)(pcmk__output_t *out)
void(* end_list)(pcmk__output_t *out)
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
struct private_data_s private_data_t
#define do_crm_log(level, fmt, args...)
Log a message.
void(* subprocess_output)(pcmk__output_t *out, int exit_status, const char *proc_stdout, const char *proc_stderr)
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
GOptionEntry pcmk__log_output_entries[]
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(* spacer)(pcmk__output_t *out)
void(* progress)(pcmk__output_t *out, bool end)
FILE * dest
Where output should be written.
const xmlChar * pcmkXmlStr
#define crm_err(fmt, args...)
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
void(* free_priv)(pcmk__output_t *out)
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(* prompt)(const char *prompt, bool echo, char **dest)
int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3