log.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /* Copyright (c) 2001, Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /* $Id$ */
  7. const char log_c_id[] = "$Id$";
  8. /**
  9. * \file log.c
  10. * \brief Functions to send messages to log files or the console.
  11. **/
  12. #include "orconfig.h"
  13. #include <stdarg.h>
  14. #include <assert.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #ifdef HAVE_SYS_TIME_H
  19. #include <sys/time.h>
  20. #endif
  21. #ifdef HAVE_TIME_H
  22. #include <time.h>
  23. #endif
  24. #include "./util.h"
  25. #include "./log.h"
  26. #include <event.h>
  27. #define TRUNCATED_STR "[...truncated]"
  28. #define TRUNCATED_STR_LEN 14
  29. /** Information for a single logfile; only used in log.c */
  30. typedef struct logfile_t {
  31. struct logfile_t *next; /**< Next logfile_t in the linked list. */
  32. char *filename; /**< Filename to open. */
  33. FILE *file; /**< Stream to receive log messages. */
  34. int seems_dead; /**< Boolean: true if the stream seems to be kaput. */
  35. int needs_close; /**< Boolean: true if the stream gets closed on shutdown. */
  36. int min_loglevel; /**< Lowest severity level to send to this stream. */
  37. int max_loglevel; /**< Highest severity level to send to this stream. */
  38. int is_temporary; /**< Boolean: close after initializing logging subsystem.*/
  39. int is_syslog; /**< Boolean: send messages to syslog. */
  40. log_callback callback; /**< If not NULL, send messages to this function. */
  41. } logfile_t;
  42. /** Helper: map a log severity to descriptive string. */
  43. static INLINE const char *
  44. sev_to_string(int severity)
  45. {
  46. switch (severity) {
  47. case LOG_DEBUG: return "debug";
  48. case LOG_INFO: return "info";
  49. case LOG_NOTICE: return "notice";
  50. case LOG_WARN: return "warn";
  51. case LOG_ERR: return "err";
  52. default: assert(0); return "UNKNOWN";
  53. }
  54. }
  55. /** Helper: decide whether to include the function name in the log message. */
  56. static INLINE int
  57. should_log_function_name(uint32_t domain, int severity)
  58. {
  59. switch (severity) {
  60. case LOG_DEBUG:
  61. case LOG_INFO:
  62. /* All debugging messages occur in interesting places. */
  63. return 1;
  64. case LOG_NOTICE:
  65. case LOG_WARN:
  66. case LOG_ERR:
  67. /* We care about places where bugs occur. */
  68. return (domain == LD_BUG);
  69. default:
  70. assert(0); return 0;
  71. }
  72. }
  73. /* XXXX We should really have this protected by a mutex or something;
  74. * XXXX see bug 222. */
  75. /** Linked list of logfile_t. */
  76. static logfile_t *logfiles = NULL;
  77. #ifdef HAVE_SYSLOG_H
  78. static int syslog_count = 0;
  79. #endif
  80. /* What's the lowest log level anybody cares about? */
  81. int _log_global_min_severity = LOG_NOTICE;
  82. static void delete_log(logfile_t *victim);
  83. static void close_log(logfile_t *victim);
  84. /** Name of the application: used to generate the message we write at the
  85. * start of each new log. */
  86. static char *appname = NULL;
  87. /** Set the "application name" for the logs to <b>name</b>: we'll use this
  88. * name in the message we write when starting up, and at the start of each new
  89. * log.
  90. *
  91. * Tor uses this string to write the version number to the log file. */
  92. void
  93. log_set_application_name(const char *name)
  94. {
  95. tor_free(appname);
  96. appname = name ? tor_strdup(name) : NULL;
  97. }
  98. /** Helper: Write the standard prefix for log lines to a
  99. * <b>buf_len</b> character buffer in <b>buf</b>.
  100. */
  101. static INLINE size_t
  102. _log_prefix(char *buf, size_t buf_len, int severity)
  103. {
  104. time_t t;
  105. struct timeval now;
  106. struct tm tm;
  107. size_t n;
  108. int r;
  109. tor_gettimeofday(&now);
  110. t = (time_t)now.tv_sec;
  111. n = strftime(buf, buf_len, "%b %d %H:%M:%S", tor_localtime_r(&t, &tm));
  112. r = tor_snprintf(buf+n, buf_len-n, ".%.3ld [%s] ",
  113. (long)now.tv_usec / 1000, sev_to_string(severity));
  114. if (r<0)
  115. return buf_len-1;
  116. else
  117. return n+r;
  118. }
  119. /** If lf refers to an actual file that we have just opened, and the file
  120. * contains no data, log an "opening new logfile" message at the top.
  121. *
  122. * Return -1 if the log is broken and needs to be deleted, else return 0.
  123. */
  124. static int
  125. log_tor_version(logfile_t *lf, int reset)
  126. {
  127. char buf[256];
  128. size_t n;
  129. int is_new;
  130. if (!lf->needs_close)
  131. /* If it doesn't get closed, it isn't really a file. */
  132. return 0;
  133. if (lf->is_temporary)
  134. /* If it's temporary, it isn't really a file. */
  135. return 0;
  136. #ifdef HAVE_FTELLO
  137. is_new = (ftello(lf->file) == 0);
  138. #else
  139. is_new = (ftell(lf->file) == 0);
  140. #endif
  141. if (reset && !is_new)
  142. /* We are resetting, but we aren't at the start of the file; no
  143. * need to log again. */
  144. return 0;
  145. n = _log_prefix(buf, sizeof(buf), LOG_NOTICE);
  146. if (appname) {
  147. tor_snprintf(buf+n, sizeof(buf)-n,
  148. "%s opening %slog file.\n", appname, is_new?"new ":"");
  149. } else {
  150. tor_snprintf(buf+n, sizeof(buf)-n,
  151. "Tor %s opening %slog file.\n", VERSION, is_new?"new ":"");
  152. }
  153. if (fputs(buf, lf->file) == EOF ||
  154. fflush(lf->file) == EOF) /* error */
  155. return -1; /* failed */
  156. return 0;
  157. }
  158. /** Helper: Format a log message into a fixed-sized buffer. (This is
  159. * factored out of <b>logv</b> so that we never format a message more
  160. * than once.) Return a pointer to the first character of the message
  161. * portion of the formatted string.
  162. */
  163. static INLINE char *
  164. format_msg(char *buf, size_t buf_len,
  165. uint32_t domain, int severity, const char *funcname,
  166. const char *format, va_list ap)
  167. {
  168. size_t n;
  169. int r;
  170. char *end_of_prefix;
  171. tor_assert(buf_len >= 2); /* prevent integer underflow */
  172. buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
  173. n = _log_prefix(buf, buf_len, severity);
  174. end_of_prefix = buf+n;
  175. if (funcname && should_log_function_name(domain, severity)) {
  176. r = tor_snprintf(buf+n, buf_len-n, "%s(): ", funcname);
  177. if (r<0)
  178. n = strlen(buf);
  179. else
  180. n += r;
  181. }
  182. if (domain == LD_BUG && buf_len-n > 6) {
  183. memcpy(buf+n, "Bug: ", 6);
  184. n += 5;
  185. }
  186. r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
  187. if (r < 0) {
  188. /* The message was too long; overwrite the end of the buffer with
  189. * "[...truncated]" */
  190. if (buf_len >= TRUNCATED_STR_LEN) {
  191. int offset = buf_len-TRUNCATED_STR_LEN;
  192. /* We have an extra 2 characters after buf_len to hold the \n\0,
  193. * so it's safe to add 1 to the size here. */
  194. strlcpy(buf+offset, TRUNCATED_STR, buf_len-offset+1);
  195. }
  196. /* Set 'n' to the end of the buffer, where we'll be writing \n\0.
  197. * Since we already subtracted 2 from buf_len, this is safe.*/
  198. n = buf_len;
  199. } else {
  200. n += r;
  201. }
  202. buf[n]='\n';
  203. buf[n+1]='\0';
  204. return end_of_prefix;
  205. }
  206. /** Helper: sends a message to the appropriate logfiles, at loglevel
  207. * <b>severity</b>. If provided, <b>funcname</b> is prepended to the
  208. * message. The actual message is derived as from tor_snprintf(format,ap).
  209. */
  210. static void
  211. logv(int severity, uint32_t domain, const char *funcname, const char *format,
  212. va_list ap)
  213. {
  214. char buf[10024];
  215. int formatted = 0;
  216. logfile_t *lf;
  217. char *end_of_prefix=NULL;
  218. assert(format);
  219. lf = logfiles;
  220. while (lf) {
  221. if (severity > lf->min_loglevel || severity < lf->max_loglevel) {
  222. lf = lf->next;
  223. continue;
  224. }
  225. if (! (lf->file || lf->is_syslog || lf->callback)) {
  226. lf = lf->next;
  227. continue;
  228. }
  229. if (lf->seems_dead) {
  230. lf = lf->next;
  231. continue;
  232. }
  233. if (!formatted) {
  234. end_of_prefix =
  235. format_msg(buf, sizeof(buf), domain, severity, funcname, format, ap);
  236. formatted = 1;
  237. }
  238. if (lf->is_syslog) {
  239. #ifdef HAVE_SYSLOG_H
  240. /* XXXX Some syslog implementations have scary limits on the length of
  241. * what you can pass them. Can/should we detect this? */
  242. syslog(severity, "%s", end_of_prefix);
  243. #endif
  244. lf = lf->next;
  245. continue;
  246. } else if (lf->callback) {
  247. lf->callback(severity, domain, end_of_prefix);
  248. lf = lf->next;
  249. continue;
  250. }
  251. if (fputs(buf, lf->file) == EOF ||
  252. fflush(lf->file) == EOF) { /* error */
  253. /* don't log the error! mark this log entry to be blown away, and
  254. * continue. */
  255. lf->seems_dead = 1;
  256. }
  257. lf = lf->next;
  258. }
  259. }
  260. /** Output a message to the log. */
  261. void
  262. _log(int severity, uint32_t domain, const char *format, ...)
  263. {
  264. va_list ap;
  265. va_start(ap,format);
  266. logv(severity, domain, NULL, format, ap);
  267. va_end(ap);
  268. }
  269. /** Output a message to the log, prefixed with a function name <b>fn</b>. */
  270. #ifdef __GNUC__
  271. void
  272. _log_fn(int severity, uint32_t domain, const char *fn, const char *format, ...)
  273. {
  274. va_list ap;
  275. va_start(ap,format);
  276. logv(severity, domain, fn, format, ap);
  277. va_end(ap);
  278. }
  279. #else
  280. const char *_log_fn_function_name=NULL;
  281. void
  282. _log_fn(int severity, uint32_t domain, const char *format, ...)
  283. {
  284. va_list ap;
  285. va_start(ap,format);
  286. logv(severity, domain, _log_fn_function_name, format, ap);
  287. va_end(ap);
  288. _log_fn_function_name = NULL;
  289. }
  290. void
  291. _log_debug(uint32_t domain, const char *format, ...)
  292. {
  293. va_list ap;
  294. va_start(ap,format);
  295. logv(LOG_DEBUG, domain, _log_fn_function_name, format, ap);
  296. va_end(ap);
  297. _log_fn_function_name = NULL;
  298. }
  299. void
  300. _log_info(uint32_t domain, const char *format, ...)
  301. {
  302. va_list ap;
  303. va_start(ap,format);
  304. logv(LOG_INFO, domain, _log_fn_function_name, format, ap);
  305. va_end(ap);
  306. _log_fn_function_name = NULL;
  307. }
  308. void
  309. _log_notice(uint32_t domain, const char *format, ...)
  310. {
  311. va_list ap;
  312. va_start(ap,format);
  313. logv(LOG_NOTICE, domain, _log_fn_function_name, format, ap);
  314. va_end(ap);
  315. _log_fn_function_name = NULL;
  316. }
  317. void
  318. _log_warn(uint32_t domain, const char *format, ...)
  319. {
  320. va_list ap;
  321. va_start(ap,format);
  322. logv(LOG_WARN, domain, _log_fn_function_name, format, ap);
  323. va_end(ap);
  324. _log_fn_function_name = NULL;
  325. }
  326. void
  327. _log_err(uint32_t domain, const char *format, ...)
  328. {
  329. va_list ap;
  330. va_start(ap,format);
  331. logv(LOG_ERR, domain, _log_fn_function_name, format, ap);
  332. va_end(ap);
  333. _log_fn_function_name = NULL;
  334. }
  335. #endif
  336. /** Close all open log files, and free other static memory. */
  337. void
  338. logs_free_all(void)
  339. {
  340. logfile_t *victim, *next;
  341. next = logfiles;
  342. logfiles = NULL;
  343. while (next) {
  344. victim = next;
  345. next = next->next;
  346. close_log(victim);
  347. tor_free(victim->filename);
  348. tor_free(victim);
  349. }
  350. tor_free(appname);
  351. }
  352. /** Remove and free the log entry <b>victim</b> from the linked-list
  353. * logfiles (it is probably present, but it might not be due to thread
  354. * racing issues). After this function is called, the caller shouldn't
  355. * refer to <b>victim</b> anymore.
  356. *
  357. * Long-term, we need to do something about races in the log subsystem
  358. * in general. See bug 222 for more details.
  359. */
  360. static void
  361. delete_log(logfile_t *victim)
  362. {
  363. logfile_t *tmpl;
  364. if (victim == logfiles)
  365. logfiles = victim->next;
  366. else {
  367. for (tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ;
  368. // tor_assert(tmpl);
  369. // tor_assert(tmpl->next == victim);
  370. if (!tmpl)
  371. return;
  372. tmpl->next = victim->next;
  373. }
  374. tor_free(victim->filename);
  375. tor_free(victim);
  376. }
  377. /** Helper: release system resources (but not memory) held by a single
  378. * logfile_t. */
  379. static void
  380. close_log(logfile_t *victim)
  381. {
  382. if (victim->needs_close && victim->file) {
  383. fclose(victim->file);
  384. } else if (victim->is_syslog) {
  385. #ifdef HAVE_SYSLOG_H
  386. if (--syslog_count == 0) {
  387. /* There are no other syslogs; close the logging facility. */
  388. closelog();
  389. }
  390. #endif
  391. }
  392. }
  393. /** Add a log handler to send all messages of severity <b>loglevel</b>
  394. * or higher to <b>stream</b>. */
  395. void
  396. add_stream_log(int loglevelMin, int loglevelMax,
  397. const char *name, FILE *stream)
  398. {
  399. logfile_t *lf;
  400. lf = tor_malloc_zero(sizeof(logfile_t));
  401. lf->filename = tor_strdup(name);
  402. lf->min_loglevel = loglevelMin;
  403. lf->max_loglevel = loglevelMax;
  404. lf->file = stream;
  405. lf->next = logfiles;
  406. logfiles = lf;
  407. _log_global_min_severity = get_min_log_level();
  408. }
  409. /** Add a log handler to receive messages during startup (before the real
  410. * logs are initialized).
  411. */
  412. void
  413. add_temp_log(void)
  414. {
  415. add_stream_log(LOG_NOTICE, LOG_ERR, "<temp>", stdout);
  416. logfiles->is_temporary = 1;
  417. _log_global_min_severity = get_min_log_level();
  418. }
  419. /**
  420. * Add a log handler to send messages of severity between
  421. * <b>logLevelmin</b> and <b>logLevelMax</b> to the function
  422. * <b>cb</b>.
  423. */
  424. int
  425. add_callback_log(int loglevelMin, int loglevelMax, log_callback cb)
  426. {
  427. logfile_t *lf;
  428. lf = tor_malloc_zero(sizeof(logfile_t));
  429. lf->min_loglevel = loglevelMin;
  430. lf->max_loglevel = loglevelMax;
  431. lf->filename = tor_strdup("<callback>");
  432. lf->callback = cb;
  433. lf->next = logfiles;
  434. logfiles = lf;
  435. _log_global_min_severity = get_min_log_level();
  436. return 0;
  437. }
  438. /** Adjust the configured severity of any logs whose callback function is
  439. * <b>cb</b>. */
  440. void
  441. change_callback_log_severity(int loglevelMin, int loglevelMax,
  442. log_callback cb)
  443. {
  444. logfile_t *lf;
  445. for (lf = logfiles; lf; lf = lf->next) {
  446. if (lf->callback == cb) {
  447. lf->min_loglevel = loglevelMin;
  448. lf->max_loglevel = loglevelMax;
  449. }
  450. }
  451. _log_global_min_severity = get_min_log_level();
  452. }
  453. /** Close any log handlers added by add_temp_log or marked by mark_logs_temp */
  454. void
  455. close_temp_logs(void)
  456. {
  457. logfile_t *lf, **p;
  458. for (p = &logfiles; *p; ) {
  459. if ((*p)->is_temporary) {
  460. lf = *p;
  461. /* we use *p here to handle the edge case of the head of the list */
  462. *p = (*p)->next;
  463. close_log(lf);
  464. tor_free(lf->filename);
  465. tor_free(lf);
  466. } else {
  467. p = &((*p)->next);
  468. }
  469. }
  470. _log_global_min_severity = get_min_log_level();
  471. }
  472. /** Make all currently temporary logs (set to be closed by close_temp_logs)
  473. * live again, and close all non-temporary logs. */
  474. void
  475. rollback_log_changes(void)
  476. {
  477. logfile_t *lf;
  478. for (lf = logfiles; lf; lf = lf->next)
  479. lf->is_temporary = ! lf->is_temporary;
  480. close_temp_logs();
  481. }
  482. /** Configure all log handles to be closed by close_temp_logs */
  483. void
  484. mark_logs_temp(void)
  485. {
  486. logfile_t *lf;
  487. for (lf = logfiles; lf; lf = lf->next)
  488. lf->is_temporary = 1;
  489. }
  490. /**
  491. * Add a log handler to send messages to <b>filename</b>. If opening
  492. * the logfile fails, -1 is returned and errno is set appropriately
  493. * (by fopen).
  494. */
  495. int
  496. add_file_log(int loglevelMin, int loglevelMax, const char *filename)
  497. {
  498. FILE *f;
  499. f = fopen(filename, "a");
  500. if (!f) return -1;
  501. add_stream_log(loglevelMin, loglevelMax, filename, f);
  502. logfiles->needs_close = 1;
  503. if (log_tor_version(logfiles, 0) < 0) {
  504. delete_log(logfiles);
  505. }
  506. _log_global_min_severity = get_min_log_level();
  507. return 0;
  508. }
  509. #ifdef HAVE_SYSLOG_H
  510. /**
  511. * Add a log handler to send messages to they system log facility.
  512. */
  513. int
  514. add_syslog_log(int loglevelMin, int loglevelMax)
  515. {
  516. logfile_t *lf;
  517. if (syslog_count++ == 0)
  518. /* This is the first syslog. */
  519. openlog("Tor", LOG_PID | LOG_NDELAY, LOGFACILITY);
  520. lf = tor_malloc_zero(sizeof(logfile_t));
  521. lf->min_loglevel = loglevelMin;
  522. lf->filename = tor_strdup("<syslog>");
  523. lf->max_loglevel = loglevelMax;
  524. lf->is_syslog = 1;
  525. lf->next = logfiles;
  526. logfiles = lf;
  527. _log_global_min_severity = get_min_log_level();
  528. return 0;
  529. }
  530. #endif
  531. /** If <b>level</b> is a valid log severity, return the corresponding
  532. * numeric value. Otherwise, return -1. */
  533. int
  534. parse_log_level(const char *level)
  535. {
  536. if (!strcasecmp(level, "err"))
  537. return LOG_ERR;
  538. if (!strcasecmp(level, "warn"))
  539. return LOG_WARN;
  540. if (!strcasecmp(level, "notice"))
  541. return LOG_NOTICE;
  542. if (!strcasecmp(level, "info"))
  543. return LOG_INFO;
  544. if (!strcasecmp(level, "debug"))
  545. return LOG_DEBUG;
  546. return -1;
  547. }
  548. /** Return the string equivalent of a given log level. */
  549. const char *
  550. log_level_to_string(int level)
  551. {
  552. return sev_to_string(level);
  553. }
  554. /** Return the least severe log level that any current log is interested in. */
  555. int
  556. get_min_log_level(void)
  557. {
  558. logfile_t *lf;
  559. int min = LOG_ERR;
  560. for (lf = logfiles; lf; lf = lf->next) {
  561. if (lf->min_loglevel > min)
  562. min = lf->min_loglevel;
  563. }
  564. return min;
  565. }
  566. /** Switch all logs to output at most verbose level. */
  567. void
  568. switch_logs_debug(void)
  569. {
  570. logfile_t *lf;
  571. for (lf = logfiles; lf; lf=lf->next) {
  572. lf->min_loglevel = LOG_DEBUG;
  573. }
  574. }
  575. #ifdef HAVE_EVENT_SET_LOG_CALLBACK
  576. /** A string which, if it appears in a libevent log, should be ignored. */
  577. static const char *suppress_msg = NULL;
  578. /** Callback function passed to event_set_log() so we can intercept
  579. * log messages from libevent. */
  580. static void
  581. libevent_logging_callback(int severity, const char *msg)
  582. {
  583. char buf[1024];
  584. size_t n;
  585. if (suppress_msg && strstr(msg, suppress_msg))
  586. return;
  587. n = strlcpy(buf, msg, sizeof(buf));
  588. if (n && n < sizeof(buf) && buf[n-1] == '\n') {
  589. buf[n-1] = '\0';
  590. }
  591. switch (severity) {
  592. case _EVENT_LOG_DEBUG:
  593. log(LOG_DEBUG, LD_NET, "Message from libevent: %s", buf);
  594. break;
  595. case _EVENT_LOG_MSG:
  596. log(LOG_INFO, LD_NET, "Message from libevent: %s", buf);
  597. break;
  598. case _EVENT_LOG_WARN:
  599. log(LOG_WARN, LD_GENERAL, "Warning from libevent: %s", buf);
  600. break;
  601. case _EVENT_LOG_ERR:
  602. log(LOG_ERR, LD_GENERAL, "Error from libevent: %s", buf);
  603. break;
  604. default:
  605. log(LOG_WARN, LD_GENERAL, "Message [%d] from libevent: %s",
  606. severity, buf);
  607. break;
  608. }
  609. }
  610. /** Set hook to intercept log messages from libevent. */
  611. void
  612. configure_libevent_logging(void)
  613. {
  614. event_set_log_callback(libevent_logging_callback);
  615. }
  616. /** Ignore any libevent log message that contains <b>msg</b>. */
  617. void
  618. suppress_libevent_log_msg(const char *msg)
  619. {
  620. suppress_msg = msg;
  621. }
  622. #else
  623. void
  624. configure_libevent_logging(void)
  625. {
  626. }
  627. void
  628. suppress_libevent_log_msg(const char *msg)
  629. {
  630. (void)msg;
  631. }
  632. #endif
  633. #if 0
  634. static void
  635. dump_log_info(logfile_t *lf)
  636. {
  637. const char *tp;
  638. if (lf->filename) {
  639. printf("=== log into \"%s\" (%s-%s) (%stemporary)\n", lf->filename,
  640. sev_to_string(lf->min_loglevel),
  641. sev_to_string(lf->max_loglevel),
  642. lf->is_temporary?"":"not ");
  643. } else if (lf->is_syslog) {
  644. printf("=== syslog (%s-%s) (%stemporary)\n",
  645. sev_to_string(lf->min_loglevel),
  646. sev_to_string(lf->max_loglevel),
  647. lf->is_temporary?"":"not ");
  648. } else {
  649. printf("=== log (%s-%s) (%stemporary)\n",
  650. sev_to_string(lf->min_loglevel),
  651. sev_to_string(lf->max_loglevel),
  652. lf->is_temporary?"":"not ");
  653. }
  654. }
  655. void
  656. describe_logs(void)
  657. {
  658. logfile_t *lf;
  659. printf("==== BEGIN LOGS ====\n");
  660. for (lf = logfiles; lf; lf = lf->next)
  661. dump_log_info(lf);
  662. printf("==== END LOGS ====\n");
  663. }
  664. #endif