failures.c revision e0f65ae5ab5c991bc5ba64ef549e0a8e4b43d20a
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/*
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen failures.c : Failure manager
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen Copyright (c) 2001-2002 Timo Sirainen
95a1a5195d56f3cf5d1e529aad668f87ad3b979bTimo Sirainen
4d4d585520538a752e9f0a4a1c019a2918f52e56Timo Sirainen Permission is hereby granted, free of charge, to any person obtaining
4d4d585520538a752e9f0a4a1c019a2918f52e56Timo Sirainen a copy of this software and associated documentation files (the
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen "Software"), to deal in the Software without restriction, including
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen without limitation the rights to use, copy, modify, merge, publish,
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen distribute, sublicense, and/or sell copies of the Software, and to
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen permit persons to whom the Software is furnished to do so, subject to
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen the following conditions:
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen The above copyright notice and this permission notice shall be
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen included in all copies or substantial portions of the Software.
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainen CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen*/
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#include "lib.h"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#include "ioloop.h"
0add8c99ca65e56dbf613595fc37c41aafff3f7fTimo Sirainen#include "fd-close-on-exec.h"
40ef82c46f6652412b068ebcdac7c3e74840a284Timo Sirainen
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen#include <stdio.h>
49d4afbb76f47c8904537d087bc81e43f1c0aa25Timo Sirainen#include <stdlib.h>
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen#include <syslog.h>
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen#include <time.h>
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen
b44faf865da16ac4d18eecd85a55b3fab6b9e63aTimo Sirainenstatic void default_panic_handler(const char *format, va_list args)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen __attr_noreturn__;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void default_fatal_handler(const char *format, va_list args)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen __attr_noreturn__;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenstatic void default_error_handler(const char *format, va_list args);
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenstatic void default_warning_handler(const char *format, va_list args);
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen/* Initialize working defaults */
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainenstatic FailureFunc panic_handler __attr_noreturn__ = default_panic_handler;
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainenstatic FailureFunc fatal_handler __attr_noreturn__ = default_fatal_handler;
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainenstatic FailureFunc error_handler = default_error_handler;
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenstatic FailureFunc warning_handler = default_warning_handler;
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainenstatic FILE *log_fd = NULL;
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainenstatic char *log_prefix = NULL, *log_stamp_format = NULL;
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainenstatic void write_prefix(void)
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen{
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen struct tm *tm;
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainen char str[256];
fee561b9d9162b130e662914fcebc9dd99b5c320Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (log_fd == NULL)
fee561b9d9162b130e662914fcebc9dd99b5c320Timo Sirainen log_fd = stderr;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen if (log_prefix != NULL)
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen fputs(log_prefix, log_fd);
041d312b44f8d41f0c9a5762c23e4d146ef7302bTimo Sirainen
041d312b44f8d41f0c9a5762c23e4d146ef7302bTimo Sirainen if (log_stamp_format != NULL) {
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen tm = localtime(&ioloop_time);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (strftime(str, sizeof(str), log_stamp_format, tm) > 0)
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen fputs(str, log_fd);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen}
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainenstatic void default_panic_handler(const char *format, va_list args)
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainen{
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainen write_prefix();
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainen
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainen fputs("Panic: ", log_fd);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen vfprintf(log_fd, printf_string_fix_format(format), args);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen fputc('\n', log_fd);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen abort();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen}
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void default_fatal_handler(const char *format, va_list args)
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen{
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen write_prefix();
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen fputs("Fatal: ", log_fd);
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen vfprintf(log_fd, printf_string_fix_format(format), args);
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen fputc('\n', log_fd);
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen exit(98);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen}
659fe5d24825b160cae512538088020d97a60239Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void default_error_handler(const char *format, va_list args)
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen{
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen int old_errno = errno;
de62ce819d59a529530da4b57be1b8d6dad13d6bTimo Sirainen
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen write_prefix();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen t_push();
659fe5d24825b160cae512538088020d97a60239Timo Sirainen fputs("Error: ", log_fd);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen vfprintf(log_fd, printf_string_fix_format(format), args);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen fputc('\n', log_fd);
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen t_pop();
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen fflush(log_fd);
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen errno = old_errno;
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen}
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainenstatic void default_warning_handler(const char *format, va_list args)
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen{
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen int old_errno = errno;
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen write_prefix();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen t_push();
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen fputs("Warning: ", log_fd);
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen vfprintf(log_fd, printf_string_fix_format(format), args);
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen fputc('\n', log_fd);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen t_pop();
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen fflush(log_fd);
a928e7efabb1672b1476e597106d4b4b81ac6f3cTimo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen errno = old_errno;
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen}
838f56174b963779a88083a0d0e85b30d2d846e7Timo Sirainen
894987bf45718f8849cc3898afdfb1ac3cfa2445Timo Sirainenvoid i_panic(const char *format, ...)
894987bf45718f8849cc3898afdfb1ac3cfa2445Timo Sirainen{
894987bf45718f8849cc3898afdfb1ac3cfa2445Timo Sirainen va_list args;
838f56174b963779a88083a0d0e85b30d2d846e7Timo Sirainen
838f56174b963779a88083a0d0e85b30d2d846e7Timo Sirainen va_start(args, format);
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen panic_handler(format, args);
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen va_end(args);
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen}
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainenvoid i_fatal(const char *format, ...)
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen{
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen va_list args;
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen
838f56174b963779a88083a0d0e85b30d2d846e7Timo Sirainen va_start(args, format);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen fatal_handler(format, args);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen va_end(args);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen}
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainenvoid i_error(const char *format, ...)
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen{
6e07b4251bf6a3cf34019c351a32a65c08392e58Timo Sirainen va_list args;
6e07b4251bf6a3cf34019c351a32a65c08392e58Timo Sirainen
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen va_start(args, format);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen error_handler(format, args);
d143077bd518de129b8d446fb58e003903e50867Timo Sirainen va_end(args);
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen}
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenvoid i_warning(const char *format, ...)
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen{
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen va_list args;
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen va_start(args, format);
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen warning_handler(format, args);
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen va_end(args);
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen}
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainenvoid i_set_panic_handler(FailureFunc func __attr_noreturn__)
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen{
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen if (func == NULL)
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen func = default_panic_handler;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen panic_handler = func;
a928e7efabb1672b1476e597106d4b4b81ac6f3cTimo Sirainen}
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainenvoid i_set_fatal_handler(FailureFunc func __attr_noreturn__)
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen{
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen if (func == NULL)
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen func = default_fatal_handler;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen fatal_handler = func;
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainen}
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainen
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainenvoid i_set_error_handler(FailureFunc func)
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if (func == NULL)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen func = default_error_handler;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen error_handler = func;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainen
e169102fb38ce788b76c2a344bee7d77079dea05Timo Sirainenvoid i_set_warning_handler(FailureFunc func)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
bd503f12eb667df389a99162f567bd8785798f55Timo Sirainen if (func == NULL)
bd503f12eb667df389a99162f567bd8785798f55Timo Sirainen func = default_warning_handler;
082e82792b8ac33ad42beac510441b37a3c50737Timo Sirainen warning_handler = func;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen}
082e82792b8ac33ad42beac510441b37a3c50737Timo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainenvoid i_syslog_panic_handler(const char *fmt, va_list args)
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen{
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen vsyslog(LOG_CRIT, fmt, args);
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen abort();
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainen
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainenvoid i_syslog_fatal_handler(const char *fmt, va_list args)
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainen{
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen vsyslog(LOG_CRIT, fmt, args);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen exit(98);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen}
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenvoid i_syslog_error_handler(const char *fmt, va_list args)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen{
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen vsyslog(LOG_ERR, fmt, args);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen}
94aa90d2d17a7aebcda5a4193a62e80ddbb169b7Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenvoid i_syslog_warning_handler(const char *fmt, va_list args)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen{
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen vsyslog(LOG_WARNING, fmt, args);
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen}
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainenvoid i_set_failure_file(const char *path, const char *prefix)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen{
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if (log_fd != NULL && log_fd != stderr)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen (void)fclose(log_fd);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen log_fd = fopen(path, "a");
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if (log_fd == NULL)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen i_fatal("Can't open log file %s: %m", path);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen fd_close_on_exec(fileno(log_fd), TRUE);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen i_free(log_prefix);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen log_prefix = i_strconcat(prefix, ": ", NULL);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen}
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenvoid i_set_failure_timestamp_format(const char *fmt)
0d0451206a91e9f96e522075dce28a89adc2325dTimo Sirainen{
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_free(log_stamp_format);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen log_stamp_format = i_strdup(fmt);
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen}
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
c2378fc4d82577009b0b5125f381387e7d74ce46Timo Sirainenvoid failures_init(void)
c2378fc4d82577009b0b5125f381387e7d74ce46Timo Sirainen{
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen}
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenvoid failures_deinit(void)
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen{
1f4f81ba81bb9fa8abe2d94f344373c230066d67Timo Sirainen if (log_fd != NULL && log_fd != stderr) {
6d3bb841d4ec2c12ac2d4ecf6146ef8d8a7dd731Timo Sirainen (void)fclose(log_fd);
6d3bb841d4ec2c12ac2d4ecf6146ef8d8a7dd731Timo Sirainen log_fd = stderr;
6d3bb841d4ec2c12ac2d4ecf6146ef8d8a7dd731Timo Sirainen }
0fa842717a8b163252e55c229c37ca0c5d7ff056Timo Sirainen}
0fa842717a8b163252e55c229c37ca0c5d7ff056Timo Sirainen