12b15cb3dSCy Schubert /* 22b15cb3dSCy Schubert * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> 32b15cb3dSCy Schubert * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 42b15cb3dSCy Schubert * 52b15cb3dSCy Schubert * Redistribution and use in source and binary forms, with or without 62b15cb3dSCy Schubert * modification, are permitted provided that the following conditions 72b15cb3dSCy Schubert * are met: 82b15cb3dSCy Schubert * 1. Redistributions of source code must retain the above copyright 92b15cb3dSCy Schubert * notice, this list of conditions and the following disclaimer. 102b15cb3dSCy Schubert * 2. Redistributions in binary form must reproduce the above copyright 112b15cb3dSCy Schubert * notice, this list of conditions and the following disclaimer in the 122b15cb3dSCy Schubert * documentation and/or other materials provided with the distribution. 132b15cb3dSCy Schubert * 3. The name of the author may not be used to endorse or promote products 142b15cb3dSCy Schubert * derived from this software without specific prior written permission. 152b15cb3dSCy Schubert * 162b15cb3dSCy Schubert * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 172b15cb3dSCy Schubert * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 182b15cb3dSCy Schubert * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 192b15cb3dSCy Schubert * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 202b15cb3dSCy Schubert * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 212b15cb3dSCy Schubert * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222b15cb3dSCy Schubert * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232b15cb3dSCy Schubert * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242b15cb3dSCy Schubert * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 252b15cb3dSCy Schubert * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262b15cb3dSCy Schubert */ 272b15cb3dSCy Schubert #ifndef LOG_INTERNAL_H_INCLUDED_ 282b15cb3dSCy Schubert #define LOG_INTERNAL_H_INCLUDED_ 292b15cb3dSCy Schubert 302b15cb3dSCy Schubert #include "event2/util.h" 312b15cb3dSCy Schubert 32*a466cc55SCy Schubert #ifdef __cplusplus 33*a466cc55SCy Schubert extern "C" { 34*a466cc55SCy Schubert #endif 35*a466cc55SCy Schubert 362b15cb3dSCy Schubert #ifdef __GNUC__ 372b15cb3dSCy Schubert #define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b))) 382b15cb3dSCy Schubert #define EV_NORETURN __attribute__((noreturn)) 392b15cb3dSCy Schubert #else 402b15cb3dSCy Schubert #define EV_CHECK_FMT(a,b) 412b15cb3dSCy Schubert #define EV_NORETURN 422b15cb3dSCy Schubert #endif 432b15cb3dSCy Schubert 442b15cb3dSCy Schubert #define EVENT_ERR_ABORT_ ((int)0xdeaddead) 452b15cb3dSCy Schubert 462b15cb3dSCy Schubert #if !defined(EVENT__DISABLE_DEBUG_MODE) || defined(USE_DEBUG) 472b15cb3dSCy Schubert #define EVENT_DEBUG_LOGGING_ENABLED 482b15cb3dSCy Schubert #endif 492b15cb3dSCy Schubert 502b15cb3dSCy Schubert #ifdef EVENT_DEBUG_LOGGING_ENABLED 51*a466cc55SCy Schubert EVENT2_CORE_EXPORT_SYMBOL extern ev_uint32_t event_debug_logging_mask_; 522b15cb3dSCy Schubert #define event_debug_get_logging_mask_() (event_debug_logging_mask_) 532b15cb3dSCy Schubert #else 542b15cb3dSCy Schubert #define event_debug_get_logging_mask_() (0) 552b15cb3dSCy Schubert #endif 562b15cb3dSCy Schubert 57*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 582b15cb3dSCy Schubert void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; 59*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 602b15cb3dSCy Schubert void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2); 61*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 622b15cb3dSCy Schubert void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN; 63*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 642b15cb3dSCy Schubert void event_sock_warn(evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(2,3); 65*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 662b15cb3dSCy Schubert void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; 67*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 682b15cb3dSCy Schubert void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2); 69*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 702b15cb3dSCy Schubert void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2); 71*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 722b15cb3dSCy Schubert void event_debugx_(const char *fmt, ...) EV_CHECK_FMT(1,2); 732b15cb3dSCy Schubert 74*a466cc55SCy Schubert EVENT2_EXPORT_SYMBOL 752b15cb3dSCy Schubert void event_logv_(int severity, const char *errstr, const char *fmt, va_list ap) 762b15cb3dSCy Schubert EV_CHECK_FMT(3,0); 772b15cb3dSCy Schubert 782b15cb3dSCy Schubert #ifdef EVENT_DEBUG_LOGGING_ENABLED 792b15cb3dSCy Schubert #define event_debug(x) do { \ 802b15cb3dSCy Schubert if (event_debug_get_logging_mask_()) { \ 812b15cb3dSCy Schubert event_debugx_ x; \ 822b15cb3dSCy Schubert } \ 832b15cb3dSCy Schubert } while (0) 842b15cb3dSCy Schubert #else 852b15cb3dSCy Schubert #define event_debug(x) ((void)0) 862b15cb3dSCy Schubert #endif 872b15cb3dSCy Schubert 882b15cb3dSCy Schubert #undef EV_CHECK_FMT 892b15cb3dSCy Schubert 90*a466cc55SCy Schubert #ifdef __cplusplus 91*a466cc55SCy Schubert } 922b15cb3dSCy Schubert #endif 93*a466cc55SCy Schubert 94*a466cc55SCy Schubert #endif /* LOG_INTERNAL_H_INCLUDED_ */ 95