Feat C++ API
A feature engineering automation tool
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logger.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 
6 #include "logger.h"
7 #include "error.h"
8 
9 namespace FT {
10 
11  namespace Util{
12 
13  Logger* Logger::instance = NULL;
14 
16  {
17  if (!instance)
18  {
19  instance = new Logger();
20  }
21 
22  return instance;
23  }
24 
26  {
27  if (instance)
28  delete instance;
29 
30  instance = NULL;
31  }
32 
33  void Logger::set_log_level(int &verbosity)
34  {
35  if(verbosity <=3 && verbosity >=0)
36  this->verbosity = verbosity;
37  else
38  {
39  WARN("'" + std::to_string(verbosity) + "' is not a valid "
40  "verbosity. Setting to default 2\n");
41  WARN("Valid Values :\n\t0 - none\n\t1 - progress\n"
42  "\t2 - minimal\n\t3 - all");
43  this->verbosity = 2;
44  verbosity = 2;
45  }
46  }
47 
49  {
50  return verbosity;
51  }
52 
54  string Logger::log(string m, int v, string sep) const
55  {
56  /* prints messages based on verbosity level. */
57  string msg = "";
58 
59  if (verbosity >= v)
60  {
61  // py::print(m);
62  // std::cout << m << sep;
63  msg += m+sep;
64  }
65  return msg;
66  }
67 
68  }
69 
70 }
Defines a multi level static logger for feat.
Definition: logger.h:24
int get_log_level()
Definition: logger.cc:48
void set_log_level(int &verbosity)
Definition: logger.cc:33
static Logger * instance
Definition: logger.h:42
string log(string m, int v, string sep="\n") const
print message with verbosity control.
Definition: logger.cc:54
static Logger * initLogger()
Definition: logger.cc:15
static void destroy()
Definition: logger.cc:25
#define WARN(err)
Definition: error.h:33
std::string to_string(const T &value)
template function to convert objects to string for logging
Definition: utils.h:422
main Feat namespace
Definition: data.cc:13