Last change
on this file since 99 was
97,
checked in by rosiere, 16 years ago
|
1) Update Prediction Table : statistics
2) Size instruction address on 30 bits
3) Change Log File
4) Add debug_level in simulation configuration file
|
-
Property svn:keywords set to
Id
|
File size:
1.5 KB
|
Rev | Line | |
---|
[88] | 1 | /* |
---|
| 2 | * $Id: Message.cpp 97 2008-12-19 15:34:00Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Common/include/Debug.h" |
---|
| 9 | #include "Common/include/Environment.h" |
---|
| 10 | #include "Common/include/ToString.h" |
---|
| 11 | #include "Common/include/ErrorMorpheo.h" |
---|
| 12 | #include <sys/types.h> |
---|
| 13 | #include <unistd.h> |
---|
| 14 | |
---|
| 15 | namespace morpheo { |
---|
| 16 | |
---|
[97] | 17 | static bool log_initialized; |
---|
| 18 | FILE * log_stream; |
---|
| 19 | |
---|
[88] | 20 | #undef FUNCTION |
---|
[97] | 21 | #define FUNCTION "log" |
---|
| 22 | FILE * log (FILE * stream) |
---|
| 23 | { |
---|
| 24 | // if log stream is initialized, take this, else return the default stream. |
---|
| 25 | return (log_initialized and (log_stream!=NULL))?log_stream:stream; |
---|
| 26 | }; |
---|
| 27 | |
---|
| 28 | #undef FUNCTION |
---|
[88] | 29 | #define FUNCTION "log_init" |
---|
[97] | 30 | void log_init (bool have_file, |
---|
| 31 | std::string directory, |
---|
| 32 | std::string file) |
---|
| 33 | { |
---|
| 34 | if (not log_initialized) |
---|
| 35 | { |
---|
| 36 | log_initialized = true; |
---|
| 37 | |
---|
| 38 | if (have_file) |
---|
| 39 | { |
---|
| 40 | // if the file is not define, take pid. |
---|
| 41 | std::string filename = directory+"/Morpheo_"+((file!="")?file:toString<pid_t>(getpid()))+".log"; |
---|
| 42 | |
---|
| 43 | log_stream = fopen (filename.c_str(), "w"); |
---|
| 44 | |
---|
| 45 | if (log_stream==NULL) |
---|
| 46 | { |
---|
| 47 | fprintf(stderr,_("%s Error create log file \"%s\", take the standard output.\n"),MSG_ERROR,filename.c_str()); |
---|
| 48 | log_stream = stdout; |
---|
| 49 | } |
---|
| 50 | else |
---|
| 51 | { |
---|
| 52 | fprintf(stdout,_("%s Create log file \"%s\".\n"),MSG_INFORMATION,filename.c_str()); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | else |
---|
| 56 | { |
---|
| 57 | log_stream = NULL; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
[88] | 62 | }; // end namespace morpheo |
---|
Note: See
TracBrowser
for help on using the repository browser.