source: trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h @ 44

Last change on this file since 44 was 44, checked in by rosiere, 17 years ago

Modification des classes d'encapsulation des interfaces.
Stable sur tous les composants actuels

File size: 3.0 KB
Line 
1#ifndef DEBUG_H
2#define DEBUG_H
3
4#include "Behavioural/include/Debug_component.h"
5#include <stdio.h>
6#include <string.h>
7#include <iostream>
8#include <sstream>
9#include <string>
10using namespace std;
11
12// Debug's Level :
13//  * None    : print elementary information
14//  * Info    : print basic information
15//  * Trace   : trace internal variable
16//  * Func    : trace call and return function
17//  * All     : print all information
18
19enum _debug_verbosity
20  {
21    DEBUG_NONE ,
22    DEBUG_INFO ,
23    DEBUG_TRACE,
24    DEBUG_FUNC ,
25    DEBUG_ALL
26  };
27
28#ifdef DEBUG
29//Debug
30
31#  define log_printf(level, component, func, str... )                   \
32do                                                                      \
33{                                                                       \
34    if ( (DEBUG == DEBUG_ALL) or                                        \
35         (( DEBUG_ ## level     <= DEBUG) and                           \
36          ( DEBUG_ ## component == true )) )                            \
37      {                                                                 \
38        if (DEBUG >= DEBUG_ALL )                                        \
39          {                                                             \
40            switch (DEBUG_ ## level)                                    \
41            {                                                           \
42            case DEBUG_NONE  : fprintf(stdout,"(none       ) "); break; \
43            case DEBUG_INFO  : fprintf(stdout,"(information) "); break; \
44            case DEBUG_TRACE : fprintf(stdout,"(trace      ) "); break; \
45            case DEBUG_FUNC  : fprintf(stdout,"(function   ) "); break; \
46            case DEBUG_ALL   : fprintf(stdout,"(all        ) "); break; \
47            default          : fprintf(stdout,"(undefine   ) "); break; \
48            }                                                           \
49          }                                                             \
50        fprintf(stdout,"<%s> ",func);                                   \
51        if (DEBUG >= DEBUG_FUNC)                                        \
52        {                                                               \
53          fprintf(stdout,"In file %s, ",__FILE__);                      \
54          fprintf(stdout,"at line %d, ",__LINE__);                      \
55        }                                                               \
56        fprintf(stdout,": ");                                           \
57        fprintf(stdout,str);                                            \
58        fprintf(stdout,"\n");                                           \
59        fflush (stdout);                                                \
60      }                                                                 \
61} while(0)
62
63#else
64// No debug
65
66#  define log_printf(level, component, func, str... )                                 \
67do                                                                                    \
68{                                                                                     \
69} while(0)
70
71#endif // DEBUG
72
73#endif // !DEBUG_H
Note: See TracBrowser for help on using the repository browser.