source: trunk/IPs/systemC/processor/Morpheo/Common/src/Message.cpp @ 100

Last change on this file since 100 was 100, checked in by rosiere, 15 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
Line 
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"
11#include "Common/include/Filename.h"
12#include <sys/types.h>
13
14namespace morpheo {
15
16  static bool log_initialized;
17  FILE * log_stream;
18 
19#undef  FUNCTION
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
28#define FUNCTION "log_init"
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.
40            std::string filename = morpheo::filename(directory,
41                                                     "Morpheo",
42                                                     "",
43                                                     "log",
44                                                     (file==""),
45                                                     (file==""),
46                                                     true);
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 
67}; // end namespace morpheo
Note: See TracBrowser for help on using the repository browser.