TaPAS  0.2
ccl-log.h
Go to the documentation of this file.
1 /*
2  * ccl-log.h -- Message displayer
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
21 #ifndef __CCL_LOG_H__
22 # define __CCL_LOG_H__
23 
24 # include <stdio.h>
25 # include <ccl/ccl-common.h>
26 
27 BEGIN_C_DECLS
28 
43  CCL_LOG_NB_TYPES
44 };
45 
51 
55 typedef void ccl_log_proc (ccl_log_type type, const char *msg, void *data);
56 
60 extern int ccl_debug_is_on;
61 
74 extern void
75 ccl_log_add_listener (ccl_log_proc *proc, void *data);
76 
82 extern void
84 
89 extern int
91 
102 extern void
103 ccl_log_push_redirection (ccl_log_type type, ccl_log_proc *proc, void *data);
104 
110 extern void
112 
121 extern void
122 ccl_log (ccl_log_type type, const char *fmt, ...);
123 
131 extern void
132 ccl_log_va (ccl_log_type type, const char *fmt, va_list pa);
133 
139 extern void
140 ccl_display (const char *fmt, ...);
141 
147 extern void
148 ccl_warning (const char *fmt, ...);
149 
155 extern void
156 ccl_panic (const char *fmt, ...);
157 
163 extern void
164 ccl_error (const char *fmt, ...);
165 
177 extern void
178 ccl_debug (const char *fmt, ...);
179 
188 extern void
189 ccl_debug_max_level (int maxlevel);
190 
194 extern void
196 
200 extern void
202 
206 extern void
207 ccl_debug_start_timed_block (const char *fmt, ...);
208 
212 extern void
214 
215 # define CCL_DEBUG_START_TIMED_BLOCK(_args) \
216  CCL_DEBUG_COND_START_TIMED_BLOCK (ccl_debug_is_on, _args)
217 
218 # define CCL_DEBUG_END_TIMED_BLOCK() \
219  CCL_DEBUG_COND_END_TIMED_BLOCK (ccl_debug_is_on)
220 
221 # define CCL_DEBUG_COND_START_TIMED_BLOCK(_cond,_args) \
222  do { if (_cond) ccl_debug_start_timed_block _args ; } while (0)
223 
224 # define CCL_DEBUG_COND_END_TIMED_BLOCK(_cond) \
225  do { if (_cond) ccl_debug_end_timed_block () ; } while (0)
226 
227 
234 extern void
235 ccl_log_redirect_to_string (ccl_log_type type, char **dst);
236 
237 extern void
238 ccl_log_redirect_to_FILE (ccl_log_type type, FILE *output);
239 
240 END_C_DECLS
241 
242 #endif /* ! __CCL_LOG_H__ */
void ccl_log(ccl_log_type type, const char *fmt,...)
Sends the message formatted using the specification fmt on the stream indicated by type...
void ccl_log_add_listener(ccl_log_proc *proc, void *data)
Adds a message listener.
Vital informations displayed before an urgent exit.
Definition: ccl-log.h:38
Debugging informations.
Definition: ccl-log.h:37
void ccl_log_va(ccl_log_type type, const char *fmt, va_list pa)
Behaves like ccl_log but the variable arguments are replaced by a va_list.
Standard output.
Definition: ccl-log.h:34
Log type freely available for user.
Definition: ccl-log.h:41
Warning information.
Definition: ccl-log.h:35
void ccl_debug_start_timed_block(const char *fmt,...)
Starts a timed block of statements.
void ccl_debug_push_tab_level(void)
Increments the level of the CCL_LOG_DEBUG stream.
void ccl_display(const char *fmt,...)
Behaves like ccl_log but the message is send on CCL_LOG_DISPLAY.
Errors stream.
Definition: ccl-log.h:36
void ccl_log_push_redirection(ccl_log_type type, ccl_log_proc *proc, void *data)
Redirects the data sent to the stream type to the listener proc.
void ccl_warning(const char *fmt,...)
Behaves like ccl_log but the message is send on CCL_LOG_WARNING.
void ccl_log_redirect_to_string(ccl_log_type type, char **dst)
Redirects messages sent to &#39;type&#39; stream into the string &#39;dst&#39;.
void ccl_log_proc(ccl_log_type type, const char *msg, void *data)
Prototype of callback functions receiving messages.
Definition: ccl-log.h:55
ccl_log_type_enum
Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed ...
Definition: ccl-log.h:33
Some useful and common macros.
Log type freely available for user.
Definition: ccl-log.h:42
void ccl_panic(const char *fmt,...)
Behaves like ccl_log but the message is send on CCL_LOG_PANIC.
void ccl_debug_end_timed_block(void)
Ends a timed block of statements.
enum ccl_log_type_enum ccl_log_type
Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed ...
Definition: ccl-log.h:50
void ccl_debug_pop_tab_level(void)
Decrements the level of the CCL_LOG_DEBUG stream.
void ccl_error(const char *fmt,...)
Behaves like ccl_log but the message is send on CCL_LOG_ERROR.
void ccl_log_pop_redirection(ccl_log_type type)
Removes redirection for the stream type.
void ccl_debug_max_level(int maxlevel)
Indicates maximal level after which nothing else is displayed. If the current level is &gt;= maxlevel th...
void ccl_log_remove_listener(ccl_log_proc *proc)
Removes the listener proc.
int ccl_debug_is_on
Boolean variable indicating if debugging traces are actived or not.
int ccl_log_has_listener(void)
Checks if a listener of messages is yet positioned.
void ccl_debug(const char *fmt,...)
Behaves like ccl_log but the message is send on CCL_LOG_DEBUG.