4
0

logconfig.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. #include "config.h"
  37. #include <corosync/totem/totem.h>
  38. #include <corosync/logsys.h>
  39. #ifdef LOGCONFIG_USE_ICMAP
  40. #include <corosync/icmap.h>
  41. #define MAP_KEYNAME_MAXLEN ICMAP_KEYNAME_MAXLEN
  42. #define map_get_string(key_name, value) icmap_get_string(key_name, value)
  43. #else
  44. #include <corosync/cmap.h>
  45. static cmap_handle_t cmap_handle;
  46. static const char *main_logfile;
  47. #define MAP_KEYNAME_MAXLEN CMAP_KEYNAME_MAXLEN
  48. #define map_get_string(key_name, value) cmap_get_string(cmap_handle, key_name, value)
  49. #endif
  50. #include "util.h"
  51. #include "logconfig.h"
  52. static char error_string_response[512];
  53. /**
  54. * insert_into_buffer
  55. * @target_buffer: a buffer where to write results
  56. * @bufferlen: tell us the size of the buffer to avoid overflows
  57. * @entry: entry that needs to be added to the buffer
  58. * @after: can either be NULL or set to a string.
  59. * if NULL, @entry is prependend to logsys_format_get buffer.
  60. * if set, @entry is added immediately after @after.
  61. *
  62. * Since the function is specific to logsys_format_get handling, it is implicit
  63. * that source is logsys_format_get();
  64. *
  65. * In case of failure, target_buffer could be left dirty. So don't trust
  66. * any data leftover in it.
  67. *
  68. * Searching for "after" assumes that there is only entry of "after"
  69. * in the source. Afterall we control the string here and for logging format
  70. * it makes little to no sense to have duplicate format entries.
  71. *
  72. * Returns: 0 on success, -1 on failure
  73. **/
  74. static int insert_into_buffer(
  75. char *target_buffer,
  76. size_t bufferlen,
  77. const char *entry,
  78. const char *after)
  79. {
  80. const char *current_format = NULL;
  81. current_format = logsys_format_get();
  82. /* if the entry is already in the format we don't add it again */
  83. if (strstr(current_format, entry) != NULL) {
  84. return -1;
  85. }
  86. /* if there is no "after", simply prepend the requested entry
  87. * otherwise go for beautiful string manipulation.... </sarcasm> */
  88. if (!after) {
  89. if (snprintf(target_buffer, bufferlen - 1, "%s%s",
  90. entry,
  91. current_format) >= bufferlen - 1) {
  92. return -1;
  93. }
  94. } else {
  95. const char *afterpos;
  96. size_t afterlen;
  97. size_t templen;
  98. /* check if after is contained in the format
  99. * and afterlen has a meaning or return an error */
  100. afterpos = strstr(current_format, after);
  101. afterlen = strlen(after);
  102. if ((!afterpos) || (!afterlen)) {
  103. return -1;
  104. }
  105. templen = afterpos - current_format + afterlen;
  106. if (snprintf(target_buffer, templen + 1, "%s", current_format)
  107. >= bufferlen - 1) {
  108. return -1;
  109. }
  110. if (snprintf(target_buffer + templen, bufferlen - ( templen + 1 ),
  111. "%s%s", entry, current_format + templen)
  112. >= bufferlen - ( templen + 1 )) {
  113. return -1;
  114. }
  115. }
  116. return 0;
  117. }
  118. /*
  119. * format set is the only global specific option that
  120. * doesn't apply at system/subsystem level.
  121. */
  122. static int corosync_main_config_format_set (
  123. const char **error_string)
  124. {
  125. const char *error_reason;
  126. char new_format_buffer[PATH_MAX];
  127. char *value = NULL;
  128. int err = 0;
  129. if (map_get_string("logging.fileline", &value) == CS_OK) {
  130. if (strcmp (value, "on") == 0) {
  131. if (!insert_into_buffer(new_format_buffer,
  132. sizeof(new_format_buffer),
  133. " %f:%l", "g]")) {
  134. err = logsys_format_set(new_format_buffer);
  135. } else
  136. if (!insert_into_buffer(new_format_buffer,
  137. sizeof(new_format_buffer),
  138. "%f:%l", NULL)) {
  139. err = logsys_format_set(new_format_buffer);
  140. }
  141. } else
  142. if (strcmp (value, "off") == 0) {
  143. /* nothing to do here */
  144. } else {
  145. error_reason = "unknown value for fileline";
  146. free(value);
  147. goto parse_error;
  148. }
  149. free(value);
  150. }
  151. if (err) {
  152. error_reason = "not enough memory to set logging format buffer";
  153. goto parse_error;
  154. }
  155. if (map_get_string("logging.function_name", &value) == CS_OK) {
  156. if (strcmp (value, "on") == 0) {
  157. if (!insert_into_buffer(new_format_buffer,
  158. sizeof(new_format_buffer),
  159. "%n:", "f:")) {
  160. err = logsys_format_set(new_format_buffer);
  161. } else
  162. if (!insert_into_buffer(new_format_buffer,
  163. sizeof(new_format_buffer),
  164. " %n", "g]")) {
  165. err = logsys_format_set(new_format_buffer);
  166. }
  167. } else
  168. if (strcmp (value, "off") == 0) {
  169. /* nothing to do here */
  170. } else {
  171. error_reason = "unknown value for function_name";
  172. free(value);
  173. goto parse_error;
  174. }
  175. free(value);
  176. }
  177. if (err) {
  178. error_reason = "not enough memory to set logging format buffer";
  179. goto parse_error;
  180. }
  181. if (map_get_string("logging.timestamp", &value) == CS_OK) {
  182. if (strcmp (value, "on") == 0) {
  183. if(!insert_into_buffer(new_format_buffer,
  184. sizeof(new_format_buffer),
  185. "%t ", NULL)) {
  186. err = logsys_format_set(new_format_buffer);
  187. }
  188. } else
  189. if (strcmp (value, "off") == 0) {
  190. /* nothing to do here */
  191. } else {
  192. error_reason = "unknown value for timestamp";
  193. free(value);
  194. goto parse_error;
  195. }
  196. free(value);
  197. }
  198. if (err) {
  199. error_reason = "not enough memory to set logging format buffer";
  200. goto parse_error;
  201. }
  202. return (0);
  203. parse_error:
  204. *error_string = error_reason;
  205. return (-1);
  206. }
  207. static int corosync_main_config_log_destination_set (
  208. const char *path,
  209. const char *key,
  210. const char *subsys,
  211. const char **error_string,
  212. unsigned int mode_mask,
  213. char deprecated,
  214. char default_value,
  215. const char *replacement)
  216. {
  217. static char formatted_error_reason[128];
  218. char *value = NULL;
  219. unsigned int mode;
  220. char key_name[MAP_KEYNAME_MAXLEN];
  221. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, key);
  222. if (map_get_string(key_name, &value) == CS_OK) {
  223. if (deprecated) {
  224. log_printf(LOGSYS_LEVEL_WARNING,
  225. "Warning: the %s config parameter has been obsoleted."
  226. " See corosync.conf man page %s directive.",
  227. key, replacement);
  228. }
  229. mode = logsys_config_mode_get (subsys);
  230. if (strcmp (value, "yes") == 0 || strcmp (value, "on") == 0) {
  231. mode |= mode_mask;
  232. if (logsys_config_mode_set(subsys, mode) < 0) {
  233. sprintf (formatted_error_reason, "unable to set mode %s", key);
  234. goto parse_error;
  235. }
  236. } else
  237. if (strcmp (value, "no") == 0 || strcmp (value, "off") == 0) {
  238. mode &= ~mode_mask;
  239. if (logsys_config_mode_set(subsys, mode) < 0) {
  240. sprintf (formatted_error_reason, "unable to unset mode %s", key);
  241. goto parse_error;
  242. }
  243. } else {
  244. sprintf (formatted_error_reason, "unknown value for %s", key);
  245. goto parse_error;
  246. }
  247. }
  248. /* Set to default if we are the top-level logger */
  249. else if (!subsys && !deprecated) {
  250. mode = logsys_config_mode_get (subsys);
  251. if (default_value) {
  252. mode |= mode_mask;
  253. }
  254. else {
  255. mode &= ~mode_mask;
  256. }
  257. if (logsys_config_mode_set(subsys, mode) < 0) {
  258. sprintf (formatted_error_reason, "unable to change mode %s", key);
  259. goto parse_error;
  260. }
  261. }
  262. free(value);
  263. return (0);
  264. parse_error:
  265. *error_string = formatted_error_reason;
  266. free(value);
  267. return (-1);
  268. }
  269. static int corosync_main_config_set (
  270. const char *path,
  271. const char *subsys,
  272. const char **error_string)
  273. {
  274. const char *error_reason = error_string_response;
  275. char *value = NULL;
  276. int mode;
  277. char key_name[MAP_KEYNAME_MAXLEN];
  278. /*
  279. * this bit abuses the internal logsys exported API
  280. * to guarantee that all configured subsystems are
  281. * initialized too.
  282. *
  283. * using this approach avoids some headaches caused
  284. * by IPC and TOTEM that have a special logging
  285. * handling requirements
  286. */
  287. if (subsys != NULL) {
  288. if (_logsys_subsys_create(subsys, NULL) < 0) {
  289. error_reason = "unable to create new logging subsystem";
  290. goto parse_error;
  291. }
  292. }
  293. mode = logsys_config_mode_get(subsys);
  294. if (mode < 0) {
  295. error_reason = "unable to get mode";
  296. goto parse_error;
  297. }
  298. if (corosync_main_config_log_destination_set (path, "to_stderr", subsys, &error_reason,
  299. LOGSYS_MODE_OUTPUT_STDERR, 0, 1, NULL) != 0)
  300. goto parse_error;
  301. if (corosync_main_config_log_destination_set (path, "to_syslog", subsys, &error_reason,
  302. LOGSYS_MODE_OUTPUT_SYSLOG, 0, 1, NULL) != 0)
  303. goto parse_error;
  304. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_facility");
  305. if (map_get_string(key_name, &value) == CS_OK) {
  306. int syslog_facility;
  307. syslog_facility = qb_log_facility2int(value);
  308. if (syslog_facility < 0) {
  309. error_reason = "unknown syslog facility specified";
  310. goto parse_error;
  311. }
  312. if (logsys_config_syslog_facility_set(subsys,
  313. syslog_facility) < 0) {
  314. error_reason = "unable to set syslog facility";
  315. goto parse_error;
  316. }
  317. free(value);
  318. }
  319. else {
  320. /* Set default here in case of a reload */
  321. if (logsys_config_syslog_facility_set(subsys,
  322. qb_log_facility2int("daemon")) < 0) {
  323. error_reason = "unable to set syslog facility";
  324. goto parse_error;
  325. }
  326. }
  327. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_level");
  328. if (map_get_string(key_name, &value) == CS_OK) {
  329. int syslog_priority;
  330. log_printf(LOGSYS_LEVEL_WARNING,
  331. "Warning: the syslog_level config parameter has been obsoleted."
  332. " See corosync.conf man page syslog_priority directive.");
  333. syslog_priority = logsys_priority_id_get(value);
  334. free(value);
  335. if (syslog_priority < 0) {
  336. error_reason = "unknown syslog level specified";
  337. goto parse_error;
  338. }
  339. if (logsys_config_syslog_priority_set(subsys,
  340. syslog_priority) < 0) {
  341. error_reason = "unable to set syslog level";
  342. goto parse_error;
  343. }
  344. }
  345. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_priority");
  346. if (map_get_string(key_name, &value) == CS_OK) {
  347. int syslog_priority;
  348. syslog_priority = logsys_priority_id_get(value);
  349. free(value);
  350. if (syslog_priority < 0) {
  351. error_reason = "unknown syslog priority specified";
  352. goto parse_error;
  353. }
  354. if (logsys_config_syslog_priority_set(subsys,
  355. syslog_priority) < 0) {
  356. error_reason = "unable to set syslog priority";
  357. goto parse_error;
  358. }
  359. }
  360. else if(strcmp(key_name, "logging.syslog_priority") == 0){
  361. if (logsys_config_syslog_priority_set(subsys,
  362. logsys_priority_id_get("info")) < 0) {
  363. error_reason = "unable to set syslog level";
  364. goto parse_error;
  365. }
  366. }
  367. #ifdef LOGCONFIG_USE_ICMAP
  368. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile");
  369. if (map_get_string(key_name, &value) == CS_OK) {
  370. if (logsys_config_file_set (subsys, &error_reason, value) < 0) {
  371. goto parse_error;
  372. }
  373. free(value);
  374. }
  375. #else
  376. if (!subsys) {
  377. if (logsys_config_file_set (subsys, &error_reason, main_logfile) < 0) {
  378. goto parse_error;
  379. }
  380. }
  381. #endif
  382. if (corosync_main_config_log_destination_set (path, "to_file", subsys, &error_reason,
  383. LOGSYS_MODE_OUTPUT_FILE, 1, 0, "to_logfile") != 0)
  384. goto parse_error;
  385. if (corosync_main_config_log_destination_set (path, "to_logfile", subsys, &error_reason,
  386. LOGSYS_MODE_OUTPUT_FILE, 0, 0, NULL) != 0)
  387. goto parse_error;
  388. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile_priority");
  389. if (map_get_string(key_name, &value) == CS_OK) {
  390. int logfile_priority;
  391. logfile_priority = logsys_priority_id_get(value);
  392. free(value);
  393. if (logfile_priority < 0) {
  394. error_reason = "unknown logfile priority specified";
  395. goto parse_error;
  396. }
  397. if (logsys_config_logfile_priority_set(subsys,
  398. logfile_priority) < 0) {
  399. error_reason = "unable to set logfile priority";
  400. goto parse_error;
  401. }
  402. }
  403. else if(strcmp(key_name,"logging.logfile_priority") == 0){
  404. if (logsys_config_logfile_priority_set(subsys,
  405. logsys_priority_id_get("info")) < 0) {
  406. error_reason = "unable to set syslog level";
  407. goto parse_error;
  408. }
  409. }
  410. snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "debug");
  411. if (map_get_string(key_name, &value) == CS_OK) {
  412. if (strcmp (value, "trace") == 0) {
  413. if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_TRACE) < 0) {
  414. error_reason = "unable to set debug trace";
  415. free(value);
  416. goto parse_error;
  417. }
  418. } else
  419. if (strcmp (value, "on") == 0) {
  420. if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_ON) < 0) {
  421. error_reason = "unable to set debug on";
  422. free(value);
  423. goto parse_error;
  424. }
  425. } else
  426. if (strcmp (value, "off") == 0) {
  427. if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
  428. error_reason = "unable to set debug off";
  429. free(value);
  430. goto parse_error;
  431. }
  432. } else {
  433. error_reason = "unknown value for debug";
  434. free(value);
  435. goto parse_error;
  436. }
  437. free(value);
  438. }
  439. else {
  440. if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
  441. error_reason = "unable to set debug off";
  442. free(value);
  443. goto parse_error;
  444. }
  445. }
  446. return (0);
  447. parse_error:
  448. *error_string = error_reason;
  449. return (-1);
  450. }
  451. static int corosync_main_config_read_logging (
  452. const char **error_string)
  453. {
  454. const char *error_reason;
  455. #ifdef LOGCONFIG_USE_ICMAP
  456. icmap_iter_t iter;
  457. const char *key_name;
  458. #else
  459. cmap_iter_handle_t iter;
  460. char key_name[CMAP_KEYNAME_MAXLEN];
  461. #endif
  462. char key_subsys[MAP_KEYNAME_MAXLEN];
  463. char key_item[MAP_KEYNAME_MAXLEN];
  464. int res;
  465. /* format set is supported only for toplevel */
  466. if (corosync_main_config_format_set(&error_reason) < 0) {
  467. goto parse_error;
  468. }
  469. if (corosync_main_config_set ("logging", NULL, &error_reason) < 0) {
  470. goto parse_error;
  471. }
  472. /*
  473. * we will need 2 of these to compensate for new logging
  474. * config format
  475. */
  476. #ifdef LOGCONFIG_USE_ICMAP
  477. iter = icmap_iter_init("logging.logger_subsys.");
  478. while ((key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  479. #else
  480. cmap_iter_init(cmap_handle, "logging.logger_subsys.", &iter);
  481. while ((cmap_iter_next(cmap_handle, iter, key_name, NULL, NULL)) == CS_OK) {
  482. #endif
  483. res = sscanf(key_name, "logging.logger_subsys.%[^.].%s", key_subsys, key_item);
  484. if (res != 2) {
  485. continue ;
  486. }
  487. if (strcmp(key_item, "subsys") != 0) {
  488. continue ;
  489. }
  490. snprintf(key_item, MAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s", key_subsys);
  491. if (corosync_main_config_set(key_item, key_subsys, &error_reason) < 0) {
  492. goto parse_error;
  493. }
  494. }
  495. #ifdef LOGCONFIG_USE_ICMAP
  496. icmap_iter_finalize(iter);
  497. #else
  498. cmap_iter_finalize(cmap_handle, iter);
  499. #endif
  500. logsys_config_apply();
  501. return 0;
  502. parse_error:
  503. *error_string = error_reason;
  504. return (-1);
  505. }
  506. #ifdef LOGCONFIG_USE_ICMAP
  507. static void main_logging_notify(
  508. int32_t event,
  509. const char *key_name,
  510. struct icmap_notify_value new_val,
  511. struct icmap_notify_value old_val,
  512. void *user_data)
  513. #else
  514. static void main_logging_notify(
  515. cmap_handle_t cmap_handle_unused,
  516. cmap_handle_t cmap_track_handle_unused,
  517. int32_t event,
  518. const char *key_name,
  519. struct cmap_notify_value new_val,
  520. struct cmap_notify_value old_val,
  521. void *user_data)
  522. #endif
  523. {
  524. const char *error_string;
  525. static int reload_in_progress = 0;
  526. /* If a full reload happens then suspend updates for individual keys until
  527. * it's all completed
  528. */
  529. if (strcmp(key_name, "config.reload_in_progress") == 0) {
  530. if (*(uint8_t *)new_val.data == 1) {
  531. reload_in_progress = 1;
  532. } else {
  533. reload_in_progress = 0;
  534. }
  535. }
  536. if (reload_in_progress) {
  537. log_printf(LOGSYS_LEVEL_DEBUG, "Ignoring key change, reload in progress. %s\n", key_name);
  538. return;
  539. }
  540. /*
  541. * Reload the logsys configuration
  542. */
  543. if (logsys_format_set(NULL) == -1) {
  544. fprintf (stderr, "Unable to setup logging format.\n");
  545. }
  546. corosync_main_config_read_logging(&error_string);
  547. }
  548. #ifdef LOGCONFIG_USE_ICMAP
  549. static void add_logsys_config_notification(void)
  550. {
  551. icmap_track_t icmap_track = NULL;
  552. icmap_track_add("logging.",
  553. ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX,
  554. main_logging_notify,
  555. NULL,
  556. &icmap_track);
  557. icmap_track_add("config.reload_in_progress",
  558. ICMAP_TRACK_ADD | ICMAP_TRACK_MODIFY,
  559. main_logging_notify,
  560. NULL,
  561. &icmap_track);
  562. }
  563. #else
  564. static void add_logsys_config_notification(void)
  565. {
  566. cmap_track_handle_t cmap_track;
  567. cmap_track_add(cmap_handle, "logging.",
  568. CMAP_TRACK_ADD | CMAP_TRACK_DELETE | CMAP_TRACK_MODIFY | CMAP_TRACK_PREFIX,
  569. main_logging_notify,
  570. NULL,
  571. &cmap_track);
  572. cmap_track_add(cmap_handle, "config.reload_in_progress",
  573. CMAP_TRACK_ADD | CMAP_TRACK_MODIFY,
  574. main_logging_notify,
  575. NULL,
  576. &cmap_track);
  577. }
  578. #endif
  579. int corosync_log_config_read (
  580. #ifndef LOGCONFIG_USE_ICMAP
  581. cmap_handle_t cmap_h,
  582. const char *default_logfile,
  583. #endif
  584. const char **error_string)
  585. {
  586. const char *error_reason = error_string_response;
  587. #ifndef LOGCONFIG_USE_ICMAP
  588. if (!cmap_h) {
  589. error_reason = "No cmap handle";
  590. return (-1);
  591. }
  592. if (!default_logfile) {
  593. error_reason = "No default logfile";
  594. return (-1);
  595. }
  596. cmap_handle = cmap_h;
  597. main_logfile = default_logfile;
  598. #endif
  599. if (corosync_main_config_read_logging(error_string) < 0) {
  600. error_reason = *error_string;
  601. goto parse_error;
  602. }
  603. add_logsys_config_notification();
  604. return 0;
  605. parse_error:
  606. snprintf (error_string_response, sizeof(error_string_response),
  607. "parse error in config: %s.\n",
  608. error_reason);
  609. *error_string = error_string_response;
  610. return (-1);
  611. }