[88] | 1 | #ifndef Morpheo_Message_h |
---|
| 2 | #define Morpheo_Message_h |
---|
[2] | 3 | /* |
---|
| 4 | * $Id: Message.h 97 2008-12-19 15:34:00Z 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") |
---|
| 35 | #else |
---|
| 36 | # define MSG_DEBUG _("[ DEBUG ]") |
---|
| 37 | # define MSG_ERROR _("[ ERROR ]") |
---|
| 38 | # define MSG_WARNING _("[ WARNING ]") |
---|
| 39 | # define MSG_INFORMATION _("[INFORMATION]") |
---|
| 40 | # define MSG_BREAKPOINT _("[ BREAK ]") |
---|
| 41 | #endif |
---|
| 42 | |
---|
| 43 | extern FILE * log_stream; |
---|
[97] | 44 | FILE * log (FILE * stream); |
---|
| 45 | void log_init (bool have_file, |
---|
| 46 | std::string directory, |
---|
| 47 | std::string file=""); |
---|
[88] | 48 | |
---|
| 49 | #define fmsg(stream,arg...) \ |
---|
[82] | 50 | do \ |
---|
| 51 | { \ |
---|
[97] | 52 | FILE * _stream = log(stream); \ |
---|
| 53 | fprintf(_stream,arg); \ |
---|
| 54 | fflush(_stream); \ |
---|
[88] | 55 | } while (0) |
---|
| 56 | |
---|
| 57 | #define fmsgDebug(stream,arg...) \ |
---|
[82] | 58 | do \ |
---|
| 59 | { \ |
---|
[88] | 60 | fmsg(stream,"%s ",MSG_DEBUG); \ |
---|
| 61 | fmsg(stream,arg); \ |
---|
[82] | 62 | } while (0) |
---|
| 63 | |
---|
[88] | 64 | #define fmsgError(stream,arg...) \ |
---|
| 65 | do \ |
---|
| 66 | { \ |
---|
| 67 | fmsg(stream,"%s ",MSG_ERROR); \ |
---|
| 68 | fmsg(stream,arg); \ |
---|
| 69 | } while (0) |
---|
[82] | 70 | |
---|
[88] | 71 | #define fmsgWarning(stream,arg...) \ |
---|
| 72 | do \ |
---|
| 73 | { \ |
---|
| 74 | fmsg(stream,"%s ",MSG_WARNING); \ |
---|
| 75 | fmsg(stream,arg); \ |
---|
| 76 | } while (0) |
---|
| 77 | |
---|
| 78 | #define fmsgInformation(stream,arg...) \ |
---|
| 79 | do \ |
---|
| 80 | { \ |
---|
| 81 | fmsg(stream,"%s ",MSG_INFORMATION); \ |
---|
| 82 | fmsg(stream,arg); \ |
---|
| 83 | } while (0) |
---|
| 84 | |
---|
| 85 | #define msg(arg...) fmsg(stdout,arg) |
---|
| 86 | #define msgDebug(arg...) fmsgDebug(stdout,arg) |
---|
| 87 | #define msgError(arg...) fmsgError(stdout,arg) |
---|
| 88 | #define msgWarning(arg...) fmsgWarning(stdout,arg) |
---|
| 89 | #define msgInformation(arg...) fmsgInformation(stdout,arg) |
---|
| 90 | #define err(arg...) fmsgError(stderr,arg) |
---|
| 91 | |
---|
[2] | 92 | }; // end namespace morpheo |
---|
[71] | 93 | #endif |
---|