23 typedef struct private_data_s {
41 #define logger(priv, fmt, args...) do { \ 42 qb_log_from_external_source(pcmk__s((priv)->function, __func__), \ 43 pcmk__s((priv)->file, __FILE__), fmt, (priv)->log_level, \ 44 (((priv)->line == 0)? __LINE__ : (priv)->line), (priv)->tags, \ 57 #define logger_va(priv, level, fmt, ap) do { \ 58 qb_log_from_external_source_va(pcmk__s((priv)->function, __func__), \ 59 pcmk__s((priv)->file, __FILE__), fmt, level, \ 60 (((priv)->line == 0)? __LINE__ : (priv)->line), (priv)->tags, \ 66 const char *proc_stdout,
const char *proc_stderr) {
74 if (out == NULL || out->
priv == NULL) {
80 g_queue_free(priv->prefixes);
92 if (out->
priv != NULL) {
97 if (out->
priv == NULL) {
103 priv->prefixes = g_queue_new();
104 priv->log_level = LOG_INFO;
118 out->
dest = freopen(NULL,
"w", out->
dest);
133 logger(priv,
"Pacemaker %s (Build: %s): %s",
137 logger(priv,
"Written by Andrew Beekhof and " 138 "the Pacemaker project contributors");
149 CRM_ASSERT((out != NULL) && (out->priv != NULL));
155 va_start(ap, format);
162 xmlNodePtr node = NULL;
176 log_begin_list(
pcmk__output_t *out, const
char *singular_noun, const
char *plural_noun,
177 const
char *format, ...) {
186 va_start(ap, format);
187 len = vasprintf(&buffer, format, ap);
194 if(strcmp(buffer,
"") == 0) {
198 g_queue_push_tail(priv->prefixes, buffer);
207 char prefix[LINE_MAX] = { 0 };
214 for (GList* gIter = priv->prefixes->head; gIter; gIter = gIter->next) {
215 if (strcmp(prefix,
"") != 0) {
216 offset += snprintf(prefix + offset, LINE_MAX - offset,
": %s", (
char *)gIter->data);
218 offset = snprintf(prefix, LINE_MAX,
"%s", (
char *)gIter->data);
222 va_start(ap, format);
223 len = vasprintf(&buffer, format, ap);
227 if (strcmp(buffer,
"") != 0) {
228 if ((
name != NULL) && (strcmp(
name,
"") != 0)) {
229 if (strcmp(prefix,
"") != 0) {
230 logger(priv,
"%s: %s: %s", prefix,
name, buffer);
235 if (strcmp(prefix,
"") != 0) {
236 logger(priv,
"%s: %s", prefix, buffer);
238 logger(priv,
"%s", buffer);
252 if (priv->prefixes == NULL) {
257 free((
char *)priv->prefixes->tail->data);
258 g_queue_pop_tail(priv->prefixes);
274 va_start(ap, format);
275 logger_va(priv, priv->log_level, format, ap);
291 va_start(ap, format);
292 logger_va(priv, QB_MAX(priv->log_level, LOG_DEBUG), format, ap);
314 log_prompt(
const char *prompt,
bool echo,
char **dest) {
322 if (retval == NULL) {
329 retval->
init = log_init;
331 retval->
finish = log_finish;
332 retval->
reset = log_reset;
339 retval->
info = log_info;
341 retval->
err = log_err;
349 retval->
spacer = log_spacer;
351 retval->
prompt = log_prompt;
365 return priv->log_level;
376 priv->log_level = log_level;
395 const char *
function, uint32_t line, uint32_t tags)
404 priv->function =
function;
void(* end_list)(pcmk__output_t *out)
#define CRM_CHECK(expr, failure_action)
int(* message)(pcmk__output_t *out, const char *message_id,...)
void pcmk__output_set_log_level(pcmk__output_t *out, uint8_t log_level)
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)
enum crm_exit_e crm_exit_t
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define PACEMAKER_VERSION
void pcmk__output_set_log_filter(pcmk__output_t *out, const char *file, const char *function, uint32_t line, uint32_t tags)
#define logger(priv, fmt, args...)
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
void(* free_priv)(pcmk__output_t *out)
bool(* init)(pcmk__output_t *out)
int(*) int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
int(*) 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.
int(*) int(* transient)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
GOptionEntry pcmk__log_output_entries[]
FILE * dest
Where output should be written.
const xmlChar * pcmkXmlStr
#define logger_va(priv, level, fmt, ap)
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)
gchar * pcmk__quote_cmdline(gchar **argv)
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)
uint8_t pcmk__output_get_log_level(const pcmk__output_t *out)