FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fei_LogFile.cpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright 2005 Sandia Corporation. */
3/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4/* non-exclusive license for use of this work by or on behalf */
5/* of the U.S. Government. Export of this program may require */
6/* a license from the United States Government. */
7/*--------------------------------------------------------------------*/
8
9#include "fei_LogFile.hpp"
10#include "fei_iostream.hpp"
11#include "fei_fstream.hpp"
12#include "fei_sstream.hpp"
13#include <string>
14
16 : output_stream_(0),
17 counter_(0)
18{
19}
20
22{
23 counter_ = 0;
24 closeOutputStream();
25}
26
27void fei::LogFile::openOutputStream(const char* path,
28 int nprocs,
29 int localproc)
30{
31 closeOutputStream();
32
33 std::string pathstr("./");
34 if (path != NULL) {
35 pathstr = path;
36 }
37
38 if (pathstr[pathstr.size()] != '/') {
39 pathstr = pathstr+"/";
40 }
41
43 osstr << pathstr << "fei_log."<<counter_<<"."<<nprocs<<"."<<localproc;
44 std::string filename = osstr.str();
45
46 ++counter_;
47
48 output_stream_ = new FEI_OFSTREAM(filename.c_str(), IOS_OUT);
49
50 if (output_stream_ == NULL || output_stream_->bad()) {
51 fei::console_out() << "couldn't open debug output file: " << filename << FEI_ENDL;
52 delete output_stream_;
53 output_stream_ = 0;
54 }
55}
56
58{
59 return( output_stream_ );
60}
61
63{
64 delete output_stream_;
65 output_stream_ = 0;
66}
67
69{
70 static fei::LogFile log_file;
71 return(log_file);
72}
73
void closeOutputStream()
Definition: fei_LogFile.cpp:62
virtual ~LogFile()
Definition: fei_LogFile.cpp:21
FEI_OSTREAM * getOutputStream()
Definition: fei_LogFile.cpp:57
void openOutputStream(const char *path=NULL, int nprocs=1, int localproc=0)
Definition: fei_LogFile.cpp:27
static LogFile & getLogFile()
Definition: fei_LogFile.cpp:68
#define FEI_OFSTREAM
Definition: fei_fstream.hpp:14
#define FEI_OSTREAM
Definition: fei_iosfwd.hpp:24
#define FEI_ENDL
#define IOS_OUT
#define FEI_OSTRINGSTREAM
Definition: fei_sstream.hpp:32
std::ostream & console_out()