19 typedef struct private_data_s {
37 #define logger(priv, fmt, args...) do { \ 38 qb_log_from_external_source(pcmk__s((priv)->function, __func__), \ 39 pcmk__s((priv)->file, __FILE__), fmt, (priv)->log_level, \ 40 (((priv)->line == 0)? __LINE__ : (priv)->line), (priv)->tags, \ 53 #define logger_va(priv, level, fmt, ap) do { \ 54 qb_log_from_external_source_va(pcmk__s((priv)->function, __func__), \ 55 pcmk__s((priv)->file, __FILE__), fmt, level, \ 56 (((priv)->line == 0)? __LINE__ : (priv)->line), (priv)->tags, \ 62 const char *proc_stdout,
const char *proc_stderr) {
70 if (out == NULL || out->
priv == NULL) {
76 g_queue_free(priv->prefixes);
88 if (out->
priv != NULL) {
93 if (out->
priv == NULL) {
99 priv->prefixes = g_queue_new();
100 priv->log_level = LOG_INFO;
114 out->
dest = freopen(NULL,
"w", out->
dest);
129 logger(priv,
"Pacemaker %s (Build: %s): %s",
133 logger(priv,
"Written by Andrew Beekhof and " 134 "the Pacemaker project contributors");
151 va_start(ap, format);
158 xmlNodePtr node = NULL;
172 log_begin_list(
pcmk__output_t *out, const
char *singular_noun, const
char *plural_noun,
173 const
char *format, ...) {
182 va_start(ap, format);
183 len = vasprintf(&buffer, format, ap);
190 if(strcmp(buffer,
"") == 0) {
194 g_queue_push_tail(priv->prefixes, buffer);
203 char prefix[LINE_MAX] = { 0 };
210 for (GList* gIter = priv->prefixes->head; gIter; gIter = gIter->next) {
211 if (strcmp(prefix,
"") != 0) {
212 offset += snprintf(prefix + offset, LINE_MAX - offset,
": %s", (
char *)gIter->data);
214 offset = snprintf(prefix, LINE_MAX,
"%s", (
char *)gIter->data);
218 va_start(ap, format);
219 len = vasprintf(&buffer, format, ap);
223 if (strcmp(buffer,
"") != 0) {
224 if ((
name != NULL) && (strcmp(
name,
"") != 0)) {
225 if (strcmp(prefix,
"") != 0) {
226 logger(priv,
"%s: %s: %s", prefix,
name, buffer);
231 if (strcmp(prefix,
"") != 0) {
232 logger(priv,
"%s: %s", prefix, buffer);
234 logger(priv,
"%s", buffer);
248 if (priv->prefixes == NULL) {
253 free((
char *)priv->prefixes->tail->data);
254 g_queue_pop_tail(priv->prefixes);
270 va_start(ap, format);
271 logger_va(priv, priv->log_level, format, ap);
287 va_start(ap, format);
288 logger_va(priv, QB_MAX(priv->log_level, LOG_DEBUG), format, ap);
310 log_prompt(
const char *prompt,
bool echo,
char **dest) {
318 if (retval == NULL) {
325 retval->
init = log_init;
327 retval->
finish = log_finish;
328 retval->
reset = log_reset;
335 retval->
info = log_info;
337 retval->
err = log_err;
345 retval->
spacer = log_spacer;
347 retval->
prompt = log_prompt;
371 return priv->log_level;
398 priv->log_level = log_level;
420 const char *
function, uint32_t line, uint32_t tags)
429 priv->function =
function;
void(* end_list)(pcmk__output_t *out)
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 pcmk__xe_set_content(xmlNode *node, const char *format,...) G_GNUC_PRINTF(2
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)
#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
FILE * dest
Where output should be written.
#define pcmk__assert(expr)
#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)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
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)