su 1.12.11devel
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00034 #ifndef SU_LOG_T 00035 00036 #define SU_LOG_T 00037 00038 typedef struct su_log_s su_log_t; 00039 #endif 00040 00041 #ifndef SU_LOG_H_NEED_SU_LOG_T 00042 00043 #ifndef SU_LOG_H 00044 00045 #define SU_LOG_H 00046 00047 #include <stdarg.h> 00048 00049 #ifndef SU_CONFIG_H 00050 #include <sofia-sip/su_config.h> 00051 #endif 00052 00053 SOFIA_BEGIN_DECLS 00054 00056 typedef void (su_logger_f)(void *stream, char const *fmt, va_list ap); 00057 00059 struct su_log_s { 00060 int log_size; 00061 char const *log_name; 00062 char const *log_env; 00063 unsigned log_default; 00064 unsigned log_level; 00065 int log_init; 00066 00067 su_logger_f *log_logger; 00068 void *log_stream; 00069 }; 00070 00071 enum { SU_LOG_MAX = 9 }; 00072 00074 #define SU_LOG_INIT(name, env, level) \ 00075 { sizeof(su_log_t), name, env, level, SU_LOG_MAX, 0, NULL, NULL, } 00076 00077 SOFIAPUBFUN void su_log(char const *fmt, ...) 00078 __attribute__ ((__format__ (printf, 1, 2))); 00079 00080 SOFIAPUBFUN void su_llog(su_log_t *log, unsigned level, char const *fmt, ...) 00081 __attribute__ ((__format__ (printf, 3, 4))); 00082 SOFIAPUBFUN void su_vllog(su_log_t *log, unsigned level, 00083 char const *fmt, va_list ap); 00084 SOFIAPUBFUN void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream); 00085 SOFIAPUBFUN void su_log_set_level(su_log_t *log, unsigned level); 00086 SOFIAPUBFUN void su_log_soft_set_level(su_log_t *log, unsigned level); 00087 SOFIAPUBFUN void su_log_init(su_log_t *log); 00088 00089 SOFIAPUBVAR su_log_t su_log_default[]; 00090 SOFIAPUBVAR su_log_t su_log_global[]; 00091 00093 SOFIAPUBFUN void su_perror(char const *s); 00094 00096 SOFIAPUBFUN void su_perror2(char const *s, int errcode); 00097 00098 SOFIA_END_DECLS 00099 00100 #endif 00101 00102 #endif /* !defined(SU_LOG_H_NEED_SU_LOG_T) */