FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_LogManager.cpp
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_utils.hpp>
10 #include <fei_LogManager.hpp>
11 #include <fei_Logger.hpp>
12 #include <fei_LogFile.hpp>
13 
14 fei::LogManager::LogManager()
15  : output_level_(NONE),
16  output_path_("./")
17 {
18 }
19 
21 {
22 }
23 
25 {
26  static fei::LogManager log_manager;
27  return(log_manager);
28 }
29 
31 {
32  return(output_level_);
33 }
34 
36 {
37  if (output_level_ == olevel) {
38  return;
39  }
40 
41  bool no_existing_output_stream = output_level_ < fei::BRIEF_LOGS;
42 
43  output_level_ = olevel;
44 
45  bool need_output_stream = output_level_ >= fei::BRIEF_LOGS;
46 
47  if (need_output_stream && no_existing_output_stream) {
48  fei::LogFile::getLogFile().openOutputStream(output_path_.c_str(),
49  numProcs_, localProc_);
50  }
51 }
52 
53 void fei::LogManager::setOutputLevel(const char* olevel)
54 {
55  setOutputLevel(fei::utils::string_to_output_level(olevel));
56 }
57 
58 void fei::LogManager::setOutputPath(const std::string& opath)
59 {
60  output_path_ = opath;
61 }
62 
63 const std::string& fei::LogManager::getOutputPath()
64 {
65  return(output_path_);
66 }
67 
68 void fei::LogManager::setNumProcs(int nprocs, int localproc)
69 {
70  numProcs_ = nprocs;
71  localProc_ = localproc;
72 }
73 
void openOutputStream(const char *path=NULL, int nprocs=1, int localproc=0)
Definition: fei_LogFile.cpp:27
const std::string & getOutputPath()
fei::OutputLevel string_to_output_level(const std::string &str)
Definition: fei_utils.cpp:58
void setNumProcs(int nprocs, int localproc)
OutputLevel getOutputLevel()
virtual ~LogManager()
OutputLevel
void setOutputLevel(OutputLevel olevel)
static LogManager & getLogManager()
static LogFile & getLogFile()
Definition: fei_LogFile.cpp:68
void setOutputPath(const std::string &opath)