corosync  3.0.1
logconfig.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2005 MontaVista Software, Inc.
3  * Copyright (c) 2006-2011 Red Hat, Inc.
4  *
5  * All rights reserved.
6  *
7  * Author: Steven Dake (sdake@redhat.com)
8  * Jan Friesse (jfriesse@redhat.com)
9  *
10  * This software licensed under BSD license, the text of which follows:
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * - Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * - Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  * - Neither the name of the MontaVista Software, Inc. nor the names of its
21  * contributors may be used to endorse or promote products derived from this
22  * software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34  * THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #include "config.h"
38 
39 #include <corosync/totem/totem.h>
40 #include <corosync/logsys.h>
41 #ifdef LOGCONFIG_USE_ICMAP
42 #include <corosync/icmap.h>
43 #define MAP_KEYNAME_MAXLEN ICMAP_KEYNAME_MAXLEN
44 #define map_get_string(key_name, value) icmap_get_string(key_name, value)
45 #else
46 #include <corosync/cmap.h>
48 static const char *main_logfile;
49 #define MAP_KEYNAME_MAXLEN CMAP_KEYNAME_MAXLEN
50 #define map_get_string(key_name, value) cmap_get_string(cmap_handle, key_name, value)
51 #endif
52 
53 #include "util.h"
54 #include "logconfig.h"
55 
56 static char error_string_response[512];
57 
79 static int insert_into_buffer(
80  char *target_buffer,
81  size_t bufferlen,
82  const char *entry,
83  const char *after)
84 {
85  const char *current_format = NULL;
86 
87  current_format = logsys_format_get();
88 
89  /* if the entry is already in the format we don't add it again */
90  if (strstr(current_format, entry) != NULL) {
91  return -1;
92  }
93 
94  /* if there is no "after", simply prepend the requested entry
95  * otherwise go for beautiful string manipulation.... </sarcasm> */
96  if (!after) {
97  if (snprintf(target_buffer, bufferlen - 1, "%s%s",
98  entry,
99  current_format) >= bufferlen - 1) {
100  return -1;
101  }
102  } else {
103  const char *afterpos;
104  size_t afterlen;
105  size_t templen;
106 
107  /* check if after is contained in the format
108  * and afterlen has a meaning or return an error */
109  afterpos = strstr(current_format, after);
110  afterlen = strlen(after);
111  if ((!afterpos) || (!afterlen)) {
112  return -1;
113  }
114 
115  templen = afterpos - current_format + afterlen;
116  if (snprintf(target_buffer, templen + 1, "%s", current_format)
117  >= bufferlen - 1) {
118  return -1;
119  }
120  if (snprintf(target_buffer + templen, bufferlen - ( templen + 1 ),
121  "%s%s", entry, current_format + templen)
122  >= bufferlen - ( templen + 1 )) {
123  return -1;
124  }
125  }
126  return 0;
127 }
128 
129 /*
130  * format set is global specific option that
131  * doesn't apply at system/subsystem level.
132  */
133 static int corosync_main_config_format_set (
134  const char **error_string)
135 {
136  const char *error_reason;
137  char new_format_buffer[PATH_MAX];
138  char *value = NULL;
139  int err = 0;
140  char timestamp_str_to_add[8];
141 
142  if (map_get_string("logging.fileline", &value) == CS_OK) {
143  if (strcmp (value, "on") == 0) {
144  if (!insert_into_buffer(new_format_buffer,
145  sizeof(new_format_buffer),
146  " %f:%l", "g]")) {
147  err = logsys_format_set(new_format_buffer);
148  } else
149  if (!insert_into_buffer(new_format_buffer,
150  sizeof(new_format_buffer),
151  "%f:%l", NULL)) {
152  err = logsys_format_set(new_format_buffer);
153  }
154  } else
155  if (strcmp (value, "off") == 0) {
156  /* nothing to do here */
157  } else {
158  error_reason = "unknown value for fileline";
159  free(value);
160  goto parse_error;
161  }
162 
163  free(value);
164  }
165 
166  if (err) {
167  error_reason = "not enough memory to set logging format buffer";
168  goto parse_error;
169  }
170 
171  if (map_get_string("logging.function_name", &value) == CS_OK) {
172  if (strcmp (value, "on") == 0) {
173  if (!insert_into_buffer(new_format_buffer,
174  sizeof(new_format_buffer),
175  "%n:", "f:")) {
176  err = logsys_format_set(new_format_buffer);
177  } else
178  if (!insert_into_buffer(new_format_buffer,
179  sizeof(new_format_buffer),
180  " %n", "g]")) {
181  err = logsys_format_set(new_format_buffer);
182  }
183  } else
184  if (strcmp (value, "off") == 0) {
185  /* nothing to do here */
186  } else {
187  error_reason = "unknown value for function_name";
188  free(value);
189  goto parse_error;
190  }
191 
192  free(value);
193  }
194 
195  if (err) {
196  error_reason = "not enough memory to set logging format buffer";
197  goto parse_error;
198  }
199 
200  memset(timestamp_str_to_add, 0, sizeof(timestamp_str_to_add));
201 
202  if (map_get_string("logging.timestamp", &value) == CS_OK) {
203  if (strcmp (value, "on") == 0) {
204  strcpy(timestamp_str_to_add, "%t");
205 #ifdef QB_FEATURE_LOG_HIRES_TIMESTAMPS
206  } else if (strcmp (value, "hires") == 0) {
207  strcpy(timestamp_str_to_add, "%T");
208 #endif
209  } else if (strcmp (value, "off") == 0) {
210  /* nothing to do here */
211  } else {
212  error_reason = "unknown value for timestamp";
213  free(value);
214  goto parse_error;
215  }
216 
217  free(value);
218  } else {
219  /*
220  * Display hires timestamp by default, otherwise standard timestamp
221  */
222 #ifdef QB_FEATURE_LOG_HIRES_TIMESTAMPS
223  strcpy(timestamp_str_to_add, "%T");
224 #else
225  strcpy(timestamp_str_to_add, "%t");
226 #endif
227  }
228 
229  if(strcmp(timestamp_str_to_add, "") != 0) {
230  strcat(timestamp_str_to_add, " ");
231  if (insert_into_buffer(new_format_buffer, sizeof(new_format_buffer),
232  timestamp_str_to_add, NULL) == 0) {
233  err = logsys_format_set(new_format_buffer);
234  }
235  }
236 
237  if (err) {
238  error_reason = "not enough memory to set logging format buffer";
239  goto parse_error;
240  }
241 
242  return (0);
243 
244 parse_error:
245  *error_string = error_reason;
246 
247  return (-1);
248 }
249 
250 /*
251  * blackbox is another global specific option that
252  * doesn't apply at system/subsystem level.
253  */
254 static int corosync_main_config_blackbox_set (
255  const char **error_string)
256 {
257  const char *error_reason;
258  char *value = NULL;
259 
260  if (map_get_string("logging.blackbox", &value) == CS_OK) {
261  if (strcmp (value, "on") == 0) {
262  (void)logsys_blackbox_set(QB_TRUE);
263  } else if (strcmp (value, "off") == 0) {
264  (void)logsys_blackbox_set(QB_FALSE);
265  } else {
266  error_reason = "unknown value for blackbox";
267  free(value);
268  goto parse_error;
269  }
270 
271  free(value);
272  } else {
273  (void)logsys_blackbox_set(QB_TRUE);
274  }
275 
276  return (0);
277 
278 parse_error:
279  *error_string = error_reason;
280 
281  return (-1);
282 }
283 
284 static int corosync_main_config_log_destination_set (
285  const char *path,
286  const char *key,
287  const char *subsys,
288  const char **error_string,
289  unsigned int mode_mask,
290  char deprecated,
291  char default_value,
292  const char *replacement)
293 {
294  static char formatted_error_reason[128];
295  char *value = NULL;
296  unsigned int mode;
297  char key_name[MAP_KEYNAME_MAXLEN];
298 
299  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, key);
300  if (map_get_string(key_name, &value) == CS_OK) {
301  if (deprecated) {
303  "Warning: the %s config parameter has been obsoleted."
304  " See corosync.conf man page %s directive.",
305  key, replacement);
306  }
307 
308  mode = logsys_config_mode_get (subsys);
309 
310  if (strcmp (value, "yes") == 0 || strcmp (value, "on") == 0) {
311  mode |= mode_mask;
312  if (logsys_config_mode_set(subsys, mode) < 0) {
313  sprintf (formatted_error_reason, "unable to set mode %s", key);
314  goto parse_error;
315  }
316  } else
317  if (strcmp (value, "no") == 0 || strcmp (value, "off") == 0) {
318  mode &= ~mode_mask;
319  if (logsys_config_mode_set(subsys, mode) < 0) {
320  sprintf (formatted_error_reason, "unable to unset mode %s", key);
321  goto parse_error;
322  }
323  } else {
324  sprintf (formatted_error_reason, "unknown value for %s", key);
325  goto parse_error;
326  }
327  }
328  /* Set to default if we are the top-level logger */
329  else if (!subsys && !deprecated) {
330 
331  mode = logsys_config_mode_get (subsys);
332  if (default_value) {
333  mode |= mode_mask;
334  }
335  else {
336  mode &= ~mode_mask;
337  }
338  if (logsys_config_mode_set(subsys, mode) < 0) {
339  sprintf (formatted_error_reason, "unable to change mode %s", key);
340  goto parse_error;
341  }
342  }
343 
344  free(value);
345  return (0);
346 
347 parse_error:
348  *error_string = formatted_error_reason;
349  free(value);
350  return (-1);
351 }
352 
353 static int corosync_main_config_set (
354  const char *path,
355  const char *subsys,
356  const char **error_string)
357 {
358  const char *error_reason = error_string_response;
359  char *value = NULL;
360  int mode;
361  char key_name[MAP_KEYNAME_MAXLEN];
362 
363  /*
364  * this bit abuses the internal logsys exported API
365  * to guarantee that all configured subsystems are
366  * initialized too.
367  *
368  * using this approach avoids some headaches caused
369  * by IPC and TOTEM that have a special logging
370  * handling requirements
371  */
372  if (subsys != NULL) {
373  if (_logsys_subsys_create(subsys, NULL) < 0) {
374  error_reason = "unable to create new logging subsystem";
375  goto parse_error;
376  }
377  }
378 
379  mode = logsys_config_mode_get(subsys);
380  if (mode < 0) {
381  error_reason = "unable to get mode";
382  goto parse_error;
383  }
384 
385  if (corosync_main_config_log_destination_set (path, "to_stderr", subsys, &error_reason,
386  LOGSYS_MODE_OUTPUT_STDERR, 0, 1, NULL) != 0)
387  goto parse_error;
388 
389  if (corosync_main_config_log_destination_set (path, "to_syslog", subsys, &error_reason,
390  LOGSYS_MODE_OUTPUT_SYSLOG, 0, 1, NULL) != 0)
391  goto parse_error;
392 
393  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_facility");
394  if (map_get_string(key_name, &value) == CS_OK) {
395  int syslog_facility;
396 
397  syslog_facility = qb_log_facility2int(value);
398  if (syslog_facility < 0) {
399  error_reason = "unknown syslog facility specified";
400  goto parse_error;
401  }
403  syslog_facility) < 0) {
404  error_reason = "unable to set syslog facility";
405  goto parse_error;
406  }
407 
408  free(value);
409  }
410  else {
411  /* Set default here in case of a reload */
413  qb_log_facility2int("daemon")) < 0) {
414  error_reason = "unable to set syslog facility";
415  goto parse_error;
416  }
417  }
418 
419  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_level");
420  if (map_get_string(key_name, &value) == CS_OK) {
421  int syslog_priority;
422 
424  "Warning: the syslog_level config parameter has been obsoleted."
425  " See corosync.conf man page syslog_priority directive.");
426 
427  syslog_priority = logsys_priority_id_get(value);
428  free(value);
429 
430  if (syslog_priority < 0) {
431  error_reason = "unknown syslog level specified";
432  goto parse_error;
433  }
435  syslog_priority) < 0) {
436  error_reason = "unable to set syslog level";
437  goto parse_error;
438  }
439  }
440 
441  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_priority");
442  if (map_get_string(key_name, &value) == CS_OK) {
443  int syslog_priority;
444 
445  syslog_priority = logsys_priority_id_get(value);
446  free(value);
447  if (syslog_priority < 0) {
448  error_reason = "unknown syslog priority specified";
449  goto parse_error;
450  }
452  syslog_priority) < 0) {
453  error_reason = "unable to set syslog priority";
454  goto parse_error;
455  }
456  }
457  else if(strcmp(key_name, "logging.syslog_priority") == 0){
459  logsys_priority_id_get("info")) < 0) {
460  error_reason = "unable to set syslog level";
461  goto parse_error;
462  }
463  }
464 
465 #ifdef LOGCONFIG_USE_ICMAP
466  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile");
467  if (map_get_string(key_name, &value) == CS_OK) {
468  if (logsys_config_file_set (subsys, &error_reason, value) < 0) {
469  goto parse_error;
470  }
471  free(value);
472  }
473 #else
474  if (!subsys) {
475  if (logsys_config_file_set (subsys, &error_reason, main_logfile) < 0) {
476  goto parse_error;
477  }
478  }
479 #endif
480 
481  if (corosync_main_config_log_destination_set (path, "to_file", subsys, &error_reason,
482  LOGSYS_MODE_OUTPUT_FILE, 1, 0, "to_logfile") != 0)
483  goto parse_error;
484 
485  if (corosync_main_config_log_destination_set (path, "to_logfile", subsys, &error_reason,
486  LOGSYS_MODE_OUTPUT_FILE, 0, 0, NULL) != 0)
487  goto parse_error;
488 
489  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile_priority");
490  if (map_get_string(key_name, &value) == CS_OK) {
491  int logfile_priority;
492 
493  logfile_priority = logsys_priority_id_get(value);
494  free(value);
495  if (logfile_priority < 0) {
496  error_reason = "unknown logfile priority specified";
497  goto parse_error;
498  }
500  logfile_priority) < 0) {
501  error_reason = "unable to set logfile priority";
502  goto parse_error;
503  }
504  }
505  else if(strcmp(key_name,"logging.logfile_priority") == 0){
507  logsys_priority_id_get("info")) < 0) {
508  error_reason = "unable to set syslog level";
509  goto parse_error;
510  }
511  }
512 
513  snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "debug");
514  if (map_get_string(key_name, &value) == CS_OK) {
515  if (strcmp (value, "trace") == 0) {
516  if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_TRACE) < 0) {
517  error_reason = "unable to set debug trace";
518  free(value);
519  goto parse_error;
520  }
521  } else
522  if (strcmp (value, "on") == 0) {
523  if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_ON) < 0) {
524  error_reason = "unable to set debug on";
525  free(value);
526  goto parse_error;
527  }
528  } else
529  if (strcmp (value, "off") == 0) {
530  if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
531  error_reason = "unable to set debug off";
532  free(value);
533  goto parse_error;
534  }
535  } else {
536  error_reason = "unknown value for debug";
537  free(value);
538  goto parse_error;
539  }
540  free(value);
541  }
542  else {
543  if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
544  error_reason = "unable to set debug off";
545  free(value);
546  goto parse_error;
547  }
548  }
549 
550  return (0);
551 
552 parse_error:
553  *error_string = error_reason;
554 
555  return (-1);
556 }
557 
558 static int corosync_main_config_read_logging (
559  const char **error_string)
560 {
561  const char *error_reason;
562 #ifdef LOGCONFIG_USE_ICMAP
563  icmap_iter_t iter;
564  const char *key_name;
565 #else
566  cmap_iter_handle_t iter;
567  char key_name[CMAP_KEYNAME_MAXLEN];
568 #endif
569  char key_subsys[MAP_KEYNAME_MAXLEN];
570  char key_item[MAP_KEYNAME_MAXLEN];
571  int res;
572 
573  /* format set is supported only for toplevel */
574  if (corosync_main_config_format_set(&error_reason) < 0) {
575  goto parse_error;
576  }
577 
578  if (corosync_main_config_blackbox_set(&error_reason) < 0) {
579  goto parse_error;
580  }
581 
582  if (corosync_main_config_set ("logging", NULL, &error_reason) < 0) {
583  goto parse_error;
584  }
585 
586  /*
587  * we will need 2 of these to compensate for new logging
588  * config format
589  */
590 #ifdef LOGCONFIG_USE_ICMAP
591  iter = icmap_iter_init("logging.logger_subsys.");
592  while ((key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) {
593 #else
594  cmap_iter_init(cmap_handle, "logging.logger_subsys.", &iter);
595  while ((cmap_iter_next(cmap_handle, iter, key_name, NULL, NULL)) == CS_OK) {
596 #endif
597  res = sscanf(key_name, "logging.logger_subsys.%[^.].%s", key_subsys, key_item);
598 
599  if (res != 2) {
600  continue ;
601  }
602 
603  if (strcmp(key_item, "subsys") != 0) {
604  continue ;
605  }
606 
607  if (snprintf(key_item, MAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s",
608  key_subsys) >= MAP_KEYNAME_MAXLEN) {
609  /*
610  * This should never happen
611  */
612  error_reason = "Can't snprintf logger_subsys key_item";
613  goto parse_error;
614  }
615 
616  if (corosync_main_config_set(key_item, key_subsys, &error_reason) < 0) {
617  goto parse_error;
618  }
619  }
620 #ifdef LOGCONFIG_USE_ICMAP
621  icmap_iter_finalize(iter);
622 #else
624 #endif
625 
627  return 0;
628 
629 parse_error:
630  *error_string = error_reason;
631 
632  return (-1);
633 }
634 
635 #ifdef LOGCONFIG_USE_ICMAP
636 static void main_logging_notify(
637  int32_t event,
638  const char *key_name,
639  struct icmap_notify_value new_val,
640  struct icmap_notify_value old_val,
641  void *user_data)
642 #else
643 static void main_logging_notify(
644  cmap_handle_t cmap_handle_unused,
645  cmap_handle_t cmap_track_handle_unused,
646  int32_t event,
647  const char *key_name,
648  struct cmap_notify_value new_val,
649  struct cmap_notify_value old_val,
650  void *user_data)
651 #endif
652 {
653  const char *error_string;
654  static int reload_in_progress = 0;
655 
656  /* If a full reload happens then suspend updates for individual keys until
657  * it's all completed
658  */
659  if (strcmp(key_name, "config.reload_in_progress") == 0) {
660  if (*(uint8_t *)new_val.data == 1) {
661  reload_in_progress = 1;
662  } else {
663  reload_in_progress = 0;
664  }
665  }
666  if (reload_in_progress) {
667  log_printf(LOGSYS_LEVEL_DEBUG, "Ignoring key change, reload in progress. %s\n", key_name);
668  return;
669  }
670 
671  /*
672  * Reload the logsys configuration
673  */
674  if (logsys_format_set(NULL) == -1) {
675  fprintf (stderr, "Unable to setup logging format.\n");
676  }
677  corosync_main_config_read_logging(&error_string);
678 }
679 
680 #ifdef LOGCONFIG_USE_ICMAP
681 static void add_logsys_config_notification(void)
682 {
683  icmap_track_t icmap_track = NULL;
684 
685  icmap_track_add("logging.",
687  main_logging_notify,
688  NULL,
689  &icmap_track);
690 
691  icmap_track_add("config.reload_in_progress",
693  main_logging_notify,
694  NULL,
695  &icmap_track);
696 }
697 #else
698 static void add_logsys_config_notification(void)
699 {
700  cmap_track_handle_t cmap_track;
701 
702  cmap_track_add(cmap_handle, "logging.",
704  main_logging_notify,
705  NULL,
706  &cmap_track);
707 
708  cmap_track_add(cmap_handle, "config.reload_in_progress",
710  main_logging_notify,
711  NULL,
712  &cmap_track);
713 }
714 #endif
715 
717 #ifndef LOGCONFIG_USE_ICMAP
718  cmap_handle_t cmap_h,
719  const char *default_logfile,
720 #endif
721  const char **error_string)
722 {
723  const char *error_reason = error_string_response;
724 
725 #ifndef LOGCONFIG_USE_ICMAP
726  if (!cmap_h) {
727  error_reason = "No cmap handle";
728  return (-1);
729  }
730  if (!default_logfile) {
731  error_reason = "No default logfile";
732  return (-1);
733  }
734  cmap_handle = cmap_h;
735  main_logfile = default_logfile;
736 #endif
737 
738  if (corosync_main_config_read_logging(error_string) < 0) {
739  error_reason = *error_string;
740  goto parse_error;
741  }
742 
743  add_logsys_config_notification();
744 
745  return 0;
746 
747 parse_error:
748  snprintf (error_string_response, sizeof(error_string_response),
749  "parse error in config: %s.\n",
750  error_reason);
751 
752  *error_string = error_string_response;
753  return (-1);
754 }
#define LOGSYS_DEBUG_TRACE
Definition: logsys.h:94
#define CMAP_TRACK_DELETE
Definition: cmap.h:79
cs_error_t cmap_track_add(cmap_handle_t handle, const char *key_name, int32_t track_type, cmap_notify_fn_t notify_fn, void *user_data, cmap_track_handle_t *cmap_track_handle)
Add tracking function for given key_name.
Definition: lib/cmap.c:977
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
Definition: icmap.c:1087
#define MAP_KEYNAME_MAXLEN
Definition: logconfig.c:49
#define CMAP_TRACK_MODIFY
Definition: cmap.h:80
uint32_t value
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
Definition: icmap.c:1108
cs_error_t cmap_iter_next(cmap_handle_t handle, cmap_iter_handle_t iter_handle, char key_name[], size_t *value_len, cmap_value_types_t *type)
Return next item in iterator iter.
Definition: lib/cmap.c:878
cmap_handle_t cmap_handle
Definition: sam.c:137
#define CMAP_TRACK_ADD
Definition: cmap.h:78
#define map_get_string(key_name, value)
Definition: logconfig.c:50
#define CMAP_KEYNAME_MAXLEN
Definition: cmap.h:69
int logsys_config_file_set(const char *subsys, const char **error_string, const char *file)
to close a logfile, just invoke this function with a NULL file or if you want to change logfile...
Definition: logsys.c:537
cs_error_t cmap_iter_init(cmap_handle_t handle, const char *prefix, cmap_iter_handle_t *cmap_iter_handle)
Initialize iterator with given prefix.
Definition: lib/cmap.c:823
int _logsys_subsys_create(const char *subsys, const char *filename)
_logsys_subsys_create
Definition: logsys.c:433
#define LOGSYS_DEBUG_ON
Definition: logsys.h:93
#define log_printf(level, format, args...)
Definition: logsys.h:323
Structure passed as new_value and old_value in change callback.
Definition: cmap.h:117
#define LOGSYS_MODE_OUTPUT_FILE
Definition: logsys.h:60
cs_error_t cmap_iter_finalize(cmap_handle_t handle, cmap_iter_handle_t iter_handle)
Finalize iterator.
Definition: lib/cmap.c:938
#define ICMAP_TRACK_DELETE
Definition: icmap.h:77
const void * data
Definition: cmap.h:120
#define LOGSYS_LEVEL_WARNING
Definition: logsys.h:73
#define ICMAP_TRACK_MODIFY
Definition: icmap.h:78
int logsys_config_debug_set(const char *subsys, unsigned int value)
enabling debug, disable message priority filtering.
Definition: logsys.c:804
int logsys_config_syslog_facility_set(const char *subsys, unsigned int facility)
per system/subsystem settings.
Definition: logsys.c:655
int logsys_config_mode_set(const char *subsys, unsigned int mode)
logsys_config_mode_set
Definition: logsys.c:503
void * user_data
Definition: sam.c:127
char * logsys_format_get(void)
logsys_format_get
Definition: logsys.c:650
#define LOGSYS_MODE_OUTPUT_SYSLOG
Definition: logsys.h:62
#define ICMAP_TRACK_ADD
Definition: icmap.h:76
#define LOGSYS_DEBUG_OFF
Definition: logsys.h:92
int corosync_log_config_read(cmap_handle_t cmap_h, const char *default_logfile, const char **error_string)
Definition: logconfig.c:716
#define LOGSYS_LEVEL_DEBUG
Definition: logsys.h:76
uint64_t cmap_track_handle_t
Definition: cmap.h:64
int logsys_config_syslog_priority_set(const char *subsys, unsigned int priority)
logsys_config_syslog_priority_set
Definition: logsys.c:662
void logsys_blackbox_set(int enable)
Definition: logsys.c:864
#define CMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem.nodeid", "totem.version", ...
Definition: cmap.h:87
void logsys_config_apply(void)
logsys_config_apply
Definition: logsys.c:790
int logsys_priority_id_get(const char *name)
logsys_priority_id_get
Definition: logsys.c:830
uint64_t cmap_iter_handle_t
Definition: cmap.h:59
unsigned int logsys_config_mode_get(const char *subsys)
logsys_config_mode_get
Definition: logsys.c:525
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
Definition: icmap.c:1081
int logsys_config_logfile_priority_set(const char *subsys, unsigned int priority)
logsys_config_logfile_priority_set
Definition: logsys.c:689
uint64_t cmap_handle_t
Definition: cmap.h:54
#define LOGSYS_MODE_OUTPUT_STDERR
Definition: logsys.h:61
qb_map_iter_t * icmap_iter_t
Itterator type.
Definition: icmap.h:123
Structure passed as new_value and old_value in change callback.
Definition: icmap.h:91
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
Definition: icmap.c:1151
int logsys_format_set(const char *format)
configuration bits that can only be done for the whole system
Definition: logsys.c:591
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem.nodeid", "totem.version", ...
Definition: icmap.h:85