su  1.13.17
su_log.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
34 #ifndef SU_LOG_T
36 #define SU_LOG_T
38 typedef struct su_log_s su_log_t;
39 #endif
40 
41 #ifndef SU_LOG_H_NEED_SU_LOG_T
42 
43 #ifndef SU_LOG_H
45 #define SU_LOG_H
46 
47 #include <stdarg.h>
48 
49 #ifndef SU_CONFIG_H
50 #include <sofia-sip/su_config.h>
51 #endif
52 
53 SOFIA_BEGIN_DECLS
54 
55 #ifdef _MSC_VER
56 #define __SOFIA_FUNC__ __FUNCTION__
57 #else
58 #define __SOFIA_FUNC__ (const char *)__func__
59 #endif
60 
61 
62 
63 
65 typedef void (su_logger_f)(void *stream, char const *fmt, va_list ap);
66 
68 struct su_log_s {
69  int log_size;
70  char const *log_name;
71  char const *log_env;
72  unsigned log_default;
73  unsigned log_level;
74  int log_init;
75 
76  su_logger_f *log_logger;
77  void *log_stream;
78 };
79 
80 enum { SU_LOG_MAX = 9 };
81 
83 #define SU_LOG_INIT(name, env, level) \
84  { sizeof(su_log_t), name, env, level, SU_LOG_MAX, 0, NULL, NULL, }
85 
86 SOFIAPUBFUN void su_log(char const *fmt, ...)
87  __attribute__ ((__format__ (printf, 1, 2)));
88 
89 SOFIAPUBFUN void _su_llog(su_log_t *log, unsigned level, const char *file, const char *func, int line, char const *fmt, ...)
90  __attribute__ ((__format__ (printf, 6, 7)));
91 SOFIAPUBFUN void _su_vllog(su_log_t *log, unsigned level, const char *file, const char *func, int line,
92  char const *fmt, va_list ap);
93 SOFIAPUBFUN void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream);
94 SOFIAPUBFUN void su_log_set_level(su_log_t *log, unsigned level);
95 SOFIAPUBFUN void su_log_soft_set_level(su_log_t *log, unsigned level);
97 
100 
102 SOFIAPUBFUN void su_perror(char const *s);
103 
104 #define su_llog(_l, _ll, _f, ...) _su_llog(_l, _ll, __FILE__, __SOFIA_FUNC__, __LINE__, _f, __VA_ARGS__)
105 #define su_vllog(_l, _ll, _f, ...) _su_vllog(_l, _ll, __FILE__, __SOFIA_FUNC__, __LINE__, _f, __VA_ARGS__)
106 
108 SOFIAPUBFUN void su_perror2(char const *s, int errcode);
109 
110 SOFIA_END_DECLS
111 
112 #endif
113 
114 #endif /* !defined(SU_LOG_H_NEED_SU_LOG_T) */
Log object.
Definition: su_log.h:68
su library configuration
#define SOFIAPUBFUN
SOFIAPUBFUN declares an exported function.
Definition: su_config.h:66
#define SOFIAPUBVAR
SOFIAPUBVAR declares an exported variable.
Definition: su_config.h:68
void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream)
Redirect a log.
Definition: su_log.c:202
void su_log(char const *fmt,...)))
Log a message to default log.
Definition: su_log.c:90
su_log_t su_log_global[]
Debug log for su module.
Definition: su_global_log.c:65
void su_perror(char const *s)
Log the latest su error message.
Definition: su_log.c:79
void _su_vllog(su_log_t *log, unsigned level, const char *file, const char *func, int line, char const *fmt, va_list ap)
Log a message with level (stdarg version).
Definition: su_log.c:118
void su_log_set_level(su_log_t *log, unsigned level)
Set log level.
Definition: su_log.c:219
void su_log_init(su_log_t *log)
Initialize a log.
Definition: su_log.c:151
void() su_logger_f(void *stream, char const *fmt, va_list ap)
Prototype for logging function.
Definition: su_log.h:65
void _su_llog(su_log_t *log, unsigned level, const char *file, const char *func, int line, char const *fmt,...)))
Log a message with level.
Definition: su_log.c:103
su_log_t su_log_default[]
Default debug log.
Definition: su_default_log.c:83
void su_perror2(char const *s, int errcode)
Log the su error message.
Definition: su_log.c:73
void su_log_soft_set_level(su_log_t *log, unsigned level)
Set log level.
Definition: su_log.c:246

Sofia-SIP 1.13.17 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.