su  1.12.11devel
 All Data Structures Files Functions Variables Typedefs Enumerator Macros Groups Pages
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
35 
36 #define SU_LOG_T
37 
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
44 
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 
56 typedef void (su_logger_f)(void *stream, char const *fmt, va_list ap);
57 
59 struct su_log_s {
60  int log_size;
61  char const *log_name;
62  char const *log_env;
63  unsigned log_default;
64  unsigned log_level;
65  int log_init;
66 
67  su_logger_f *log_logger;
68  void *log_stream;
69 };
70 
71 enum { SU_LOG_MAX = 9 };
72 
74 #define SU_LOG_INIT(name, env, level) \
75  { sizeof(su_log_t), name, env, level, SU_LOG_MAX, 0, NULL, NULL, }
76 
77 SOFIAPUBFUN void su_log(char const *fmt, ...)
78  __attribute__ ((__format__ (printf, 1, 2)));
79 
80 SOFIAPUBFUN void su_llog(su_log_t *log, unsigned level, char const *fmt, ...)
81  __attribute__ ((__format__ (printf, 3, 4)));
82 SOFIAPUBFUN void su_vllog(su_log_t *log, unsigned level,
83  char const *fmt, va_list ap);
84 SOFIAPUBFUN void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream);
85 SOFIAPUBFUN void su_log_set_level(su_log_t *log, unsigned level);
86 SOFIAPUBFUN void su_log_soft_set_level(su_log_t *log, unsigned level);
88 
91 
93 SOFIAPUBFUN void su_perror(char const *s);
94 
96 SOFIAPUBFUN void su_perror2(char const *s, int errcode);
97 
98 SOFIA_END_DECLS
99 
100 #endif
101 
102 #endif /* !defined(SU_LOG_H_NEED_SU_LOG_T) */
su_log_t su_log_default[]
Default debug log.
Definition: su_default_log.c:83
void( su_logger_f)(void *stream, char const *fmt, va_list ap)
Prototype for logging function.
Definition: su_log.h:56
void su_log(char const *fmt,...)))
Log a message to default log.
Definition: su_log.c:90
void su_log_set_level(su_log_t *log, unsigned level)
Set log level.
Definition: su_log.c:212
void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream)
Redirect a log.
Definition: su_log.c:195
void su_llog(su_log_t *log, unsigned level, char const *fmt,...)))
Log a message with level.
Definition: su_log.c:103
#define SOFIAPUBFUN
SOFIAPUBFUN declares an exported function.
Definition: su_config.h:66
su library configuration
su_log_t su_log_global[]
Debug log for su module.
Definition: su_global_log.c:65
#define SOFIAPUBVAR
SOFIAPUBVAR declares an exported variable.
Definition: su_config.h:68
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, char const *fmt, va_list ap)
Log a message with level (stdarg version).
Definition: su_log.c:113
void su_log_soft_set_level(su_log_t *log, unsigned level)
Set log level.
Definition: su_log.c:239
void su_log_init(su_log_t *log)
Initialize a log.
Definition: su_log.c:144
Log object.
Definition: su_log.h:59
void su_perror2(char const *s, int errcode)
Log the su error message.
Definition: su_log.c:73

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