TaPAS  0.2
Typedefs | Enumerations | Functions | Variables
ccl-log.h File Reference

Message displayer. More...

#include <stdio.h>
#include <ccl/ccl-common.h>

Go to the source code of this file.

Typedefs

typedef 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 on a separate stream.
 
typedef void ccl_log_proc (ccl_log_type type, const char *msg, void *data)
 Prototype of callback functions receiving messages.
 

Enumerations

enum  ccl_log_type_enum {
  CCL_LOG_DISPLAY = 0,
  CCL_LOG_WARNING,
  CCL_LOG_ERROR,
  CCL_LOG_DEBUG,
  CCL_LOG_PANIC,
  CCL_LOG_USR1,
  CCL_LOG_USR2
}
 Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed on a separate stream. More...
 

Functions

void ccl_log_add_listener (ccl_log_proc *proc, void *data)
 Adds a message listener. More...
 
void ccl_log_remove_listener (ccl_log_proc *proc)
 Removes the listener proc. More...
 
int ccl_log_has_listener (void)
 Checks if a listener of messages is yet positioned. More...
 
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. More...
 
void ccl_log_pop_redirection (ccl_log_type type)
 Removes redirection for the stream type. More...
 
void ccl_log (ccl_log_type type, const char *fmt,...)
 Sends the message formatted using the specification fmt on the stream indicated by type. The formating string is written in the same way than the one used by ccl_string_format. More...
 
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. More...
 
void ccl_display (const char *fmt,...)
 Behaves like ccl_log but the message is send on CCL_LOG_DISPLAY. More...
 
void ccl_warning (const char *fmt,...)
 Behaves like ccl_log but the message is send on CCL_LOG_WARNING. More...
 
void ccl_panic (const char *fmt,...)
 Behaves like ccl_log but the message is send on CCL_LOG_PANIC. More...
 
void ccl_error (const char *fmt,...)
 Behaves like ccl_log but the message is send on CCL_LOG_ERROR. More...
 
void ccl_debug (const char *fmt,...)
 Behaves like ccl_log but the message is send on CCL_LOG_DEBUG. More...
 
void ccl_debug_max_level (int maxlevel)
 Indicates maximal level after which nothing else is displayed. If the current level is >= maxlevel then messages sent to CCL_LOG_DEBUG are not displayed. If maxlevel < 0 then all messages are displayed. If maxlevel == 0 then no messages are displayed. More...
 
void ccl_debug_push_tab_level (void)
 Increments the level of the CCL_LOG_DEBUG stream.
 
void ccl_debug_pop_tab_level (void)
 Decrements the level of the CCL_LOG_DEBUG stream.
 
void ccl_debug_start_timed_block (const char *fmt,...)
 Starts a timed block of statements.
 
void ccl_debug_end_timed_block (void)
 Ends a timed block of statements.
 
void ccl_log_redirect_to_string (ccl_log_type type, char **dst)
 Redirects messages sent to 'type' stream into the string 'dst'. More...
 

Variables

int ccl_debug_is_on
 Boolean variable indicating if debugging traces are actived or not.
 

Detailed Description

Message displayer.

Definition in file ccl-log.h.

Enumeration Type Documentation

Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed on a separate stream.

Enumerator
CCL_LOG_DISPLAY 

Standard output.

CCL_LOG_WARNING 

Warning information.

CCL_LOG_ERROR 

Errors stream.

CCL_LOG_DEBUG 

Debugging informations.

CCL_LOG_PANIC 

Vital informations displayed before an urgent exit.

CCL_LOG_USR1 

Log type freely available for user.

CCL_LOG_USR2 

Log type freely available for user.

Definition at line 33 of file ccl-log.h.

Function Documentation

void ccl_debug ( const char *  fmt,
  ... 
)

Behaves like ccl_log but the message is send on CCL_LOG_DEBUG.

This function maintains a counter that represents a level of information. The user can request the CCL_LOG_DEBUG stream to be restricted to message occuring only when the counter is less than a maximal value.

See Also
ccl_debug_max_level, ccl_debug_push_tab_level and ccl_debug_pop_tab_level.
Parameters
fmtthe formatting string
void ccl_debug_max_level ( int  maxlevel)

Indicates maximal level after which nothing else is displayed. If the current level is >= maxlevel then messages sent to CCL_LOG_DEBUG are not displayed. If maxlevel < 0 then all messages are displayed. If maxlevel == 0 then no messages are displayed.

Parameters
maxlevelthe maximal level of information
void ccl_display ( const char *  fmt,
  ... 
)

Behaves like ccl_log but the message is send on CCL_LOG_DISPLAY.

Parameters
fmtthe formatting string
void ccl_error ( const char *  fmt,
  ... 
)

Behaves like ccl_log but the message is send on CCL_LOG_ERROR.

Parameters
fmtthe formatting string
void ccl_log ( ccl_log_type  type,
const char *  fmt,
  ... 
)

Sends the message formatted using the specification fmt on the stream indicated by type. The formating string is written in the same way than the one used by ccl_string_format.

Parameters
typethe steam where message is sent
fmtthe formatting string
void ccl_log_add_listener ( ccl_log_proc proc,
void *  data 
)

Adds a message listener.

The function registers the function proc as a message listener. Thus, each time a new message M as to be send, the following statement is executed proc (type, M, data) where type is the ccl_log_type on which the message M is sent and data is the pointer given when registering the listener.

Parameters
procthe listener function
dataa pointer to some data passed to proc each time it is called.
int ccl_log_has_listener ( void  )

Checks if a listener of messages is yet positioned.

Returns
a non-null value if there exists at list one message listener.
void ccl_log_pop_redirection ( ccl_log_type  type)

Removes redirection for the stream type.

Parameters
typethe redirected stream
Precondition
The stream type must have been redirected.
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.

Each time a message is sent on the stream type, instead of being treated by registered listeners, it is sent to proc.

Parameters
typethe stream to redirect
procthe listener function
dataa pointer to some data passed to proc each time it is called.
void ccl_log_redirect_to_string ( ccl_log_type  type,
char **  dst 
)

Redirects messages sent to 'type' stream into the string 'dst'.

Parameters
typethe redirected stream
dsta pointer to the destination string
void ccl_log_remove_listener ( ccl_log_proc proc)

Removes the listener proc.

Parameters
\procthe listerner function
Precondition
proc must be a registered function.
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.

Parameters
typethe steam where message is sent
fmtthe formatting string
pathe list of arguments.
void ccl_panic ( const char *  fmt,
  ... 
)

Behaves like ccl_log but the message is send on CCL_LOG_PANIC.

Parameters
fmtthe formatting string
void ccl_warning ( const char *  fmt,
  ... 
)

Behaves like ccl_log but the message is send on CCL_LOG_WARNING.

Parameters
fmtthe formatting string