Last change
on this file since 107 was
100,
checked in by rosiere, 16 years ago
|
1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test
|
-
Property svn:keywords set to
Id
|
File size:
1.8 KB
|
Rev | Line | |
---|
[88] | 1 | /* |
---|
| 2 | * $Id: Message.cpp 100 2009-01-08 13:06:27Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Common/include/Debug.h" |
---|
| 9 | #include "Common/include/Environment.h" |
---|
| 10 | #include "Common/include/ErrorMorpheo.h" |
---|
[100] | 11 | #include "Common/include/Filename.h" |
---|
[88] | 12 | #include <sys/types.h> |
---|
| 13 | |
---|
| 14 | namespace morpheo { |
---|
| 15 | |
---|
[97] | 16 | static bool log_initialized; |
---|
| 17 | FILE * log_stream; |
---|
| 18 | |
---|
[88] | 19 | #undef FUNCTION |
---|
[97] | 20 | #define FUNCTION "log" |
---|
| 21 | FILE * log (FILE * stream) |
---|
| 22 | { |
---|
| 23 | // if log stream is initialized, take this, else return the default stream. |
---|
| 24 | return (log_initialized and (log_stream!=NULL))?log_stream:stream; |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | #undef FUNCTION |
---|
[88] | 28 | #define FUNCTION "log_init" |
---|
[97] | 29 | void log_init (bool have_file, |
---|
| 30 | std::string directory, |
---|
| 31 | std::string file) |
---|
| 32 | { |
---|
| 33 | if (not log_initialized) |
---|
| 34 | { |
---|
| 35 | log_initialized = true; |
---|
| 36 | |
---|
| 37 | if (have_file) |
---|
| 38 | { |
---|
| 39 | // if the file is not define, take pid. |
---|
[100] | 40 | std::string filename = morpheo::filename(directory, |
---|
| 41 | "Morpheo", |
---|
| 42 | "", |
---|
| 43 | "log", |
---|
| 44 | (file==""), |
---|
| 45 | (file==""), |
---|
| 46 | true); |
---|
[97] | 47 | |
---|
| 48 | log_stream = fopen (filename.c_str(), "w"); |
---|
| 49 | |
---|
| 50 | if (log_stream==NULL) |
---|
| 51 | { |
---|
| 52 | fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str()); |
---|
| 53 | log_stream = stdout; |
---|
| 54 | } |
---|
| 55 | else |
---|
| 56 | { |
---|
| 57 | fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str()); |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | else |
---|
| 61 | { |
---|
| 62 | log_stream = NULL; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
[88] | 67 | }; // end namespace morpheo |
---|
Note: See
TracBrowser
for help on using the repository browser.