[88] | 1 | #ifndef Morpheo_Message_h |
---|
| 2 | #define Morpheo_Message_h |
---|
[2] | 3 | /* |
---|
| 4 | * $Id: Message.h 134 2009-07-15 08:41:01Z rosiere $ |
---|
| 5 | * |
---|
[71] | 6 | * [ Description ] |
---|
[2] | 7 | * |
---|
| 8 | * Routine of Test |
---|
| 9 | */ |
---|
| 10 | |
---|
[71] | 11 | #include <stdio.h> |
---|
| 12 | #include <string.h> |
---|
[82] | 13 | #include "Translation.h" |
---|
[2] | 14 | |
---|
[71] | 15 | namespace morpheo { |
---|
| 16 | |
---|
[88] | 17 | // Color |
---|
| 18 | // 31 : rouge |
---|
| 19 | // 32 : vert |
---|
| 20 | // 33 : jaune |
---|
| 21 | // 34 : bleu |
---|
| 22 | // 35 : rose |
---|
| 23 | // 36 : cyan |
---|
| 24 | // 37 : blanc |
---|
| 25 | // 38 : noir souligne |
---|
| 26 | // 39 : noir |
---|
[71] | 27 | |
---|
[88] | 28 | # define MSG_NONE _(" ") |
---|
| 29 | #ifdef PRINT_COLOR |
---|
| 30 | # define MSG_DEBUG _("[1;34m[ DEBUG ][0m") |
---|
| 31 | # define MSG_ERROR _("[1;31m[ ERROR ][0m") |
---|
| 32 | # define MSG_WARNING _("[1;35m[ WARNING ][0m") |
---|
| 33 | # define MSG_INFORMATION _("[1;32m[INFORMATION][0m") |
---|
| 34 | # define MSG_BREAKPOINT _("[1;38m[ BREAK ][0m") |
---|
[113] | 35 | # define MSG_VHDL _("[1;34m[ VHDL ][0m") |
---|
[88] | 36 | #else |
---|
| 37 | # define MSG_DEBUG _("[ DEBUG ]") |
---|
| 38 | # define MSG_ERROR _("[ ERROR ]") |
---|
| 39 | # define MSG_WARNING _("[ WARNING ]") |
---|
| 40 | # define MSG_INFORMATION _("[INFORMATION]") |
---|
| 41 | # define MSG_BREAKPOINT _("[ BREAK ]") |
---|
[113] | 42 | # define MSG_VHDL _("[ VHDL ]") |
---|
[88] | 43 | #endif |
---|
| 44 | |
---|
| 45 | extern FILE * log_stream; |
---|
[134] | 46 | extern bool log_file_generate; |
---|
[120] | 47 | |
---|
[97] | 48 | FILE * log (FILE * stream); |
---|
| 49 | void log_init (bool have_file, |
---|
[124] | 50 | bool with_date, |
---|
[120] | 51 | bool with_pid , |
---|
[97] | 52 | std::string directory, |
---|
| 53 | std::string file=""); |
---|
[88] | 54 | |
---|
| 55 | #define fmsg(stream,arg...) \ |
---|
[82] | 56 | do \ |
---|
| 57 | { \ |
---|
[97] | 58 | FILE * _stream = log(stream); \ |
---|
| 59 | fprintf(_stream,arg); \ |
---|
| 60 | fflush(_stream); \ |
---|
[88] | 61 | } while (0) |
---|
| 62 | |
---|
| 63 | #define fmsgDebug(stream,arg...) \ |
---|
[82] | 64 | do \ |
---|
| 65 | { \ |
---|
[88] | 66 | fmsg(stream,"%s ",MSG_DEBUG); \ |
---|
| 67 | fmsg(stream,arg); \ |
---|
[82] | 68 | } while (0) |
---|
| 69 | |
---|
[88] | 70 | #define fmsgError(stream,arg...) \ |
---|
| 71 | do \ |
---|
| 72 | { \ |
---|
| 73 | fmsg(stream,"%s ",MSG_ERROR); \ |
---|
| 74 | fmsg(stream,arg); \ |
---|
| 75 | } while (0) |
---|
[82] | 76 | |
---|
[88] | 77 | #define fmsgWarning(stream,arg...) \ |
---|
| 78 | do \ |
---|
| 79 | { \ |
---|
| 80 | fmsg(stream,"%s ",MSG_WARNING); \ |
---|
| 81 | fmsg(stream,arg); \ |
---|
| 82 | } while (0) |
---|
| 83 | |
---|
| 84 | #define fmsgInformation(stream,arg...) \ |
---|
| 85 | do \ |
---|
| 86 | { \ |
---|
| 87 | fmsg(stream,"%s ",MSG_INFORMATION); \ |
---|
| 88 | fmsg(stream,arg); \ |
---|
| 89 | } while (0) |
---|
| 90 | |
---|
| 91 | #define msg(arg...) fmsg(stdout,arg) |
---|
[113] | 92 | #define err(arg...) fmsgError(stderr,arg) |
---|
| 93 | |
---|
[88] | 94 | #define msgDebug(arg...) fmsgDebug(stdout,arg) |
---|
| 95 | #define msgError(arg...) fmsgError(stdout,arg) |
---|
| 96 | #define msgWarning(arg...) fmsgWarning(stdout,arg) |
---|
| 97 | #define msgInformation(arg...) fmsgInformation(stdout,arg) |
---|
| 98 | |
---|
[2] | 99 | }; // end namespace morpheo |
---|
[71] | 100 | #endif |
---|