Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
logger.cpp
Go to the documentation of this file.
1/* Brush
2copyright 2020 William La Cava
3license: GNU/GPL v3
4*/
5
6#include "logger.h"
7#include "error.h"
8
9namespace Brush { namespace Util{
10
11 Logger* Logger::instance = NULL;
12
14 {
15 if (!instance)
16 {
17 instance = new Logger();
18 }
19
20 return instance;
21 }
22
24 {
25 if (instance)
26 delete instance;
27
28 instance = NULL;
29 }
30
31 void Logger::set_log_level(int &verbosity)
32 {
34 this->verbosity = verbosity;
35 else
36 {
37 HANDLE_WARNING("'" + std::to_string(verbosity) + "' is not a valid verbosity. Setting to default 2\n");
38 HANDLE_WARNING("Valid Values :\n\t0 - none\n\t1 - progress\n\t2 - minimal\n\t3 - all");
39 this->verbosity = 2;
40 verbosity = 2;
41 }
42 }
43
45 {
46 return verbosity;
47 }
48
50 string Logger::log(string m, int v, string sep) const
51 {
52 /* prints messages based on verbosity level. */
53 string msg = "";
54
55 if (verbosity >= v)
56 {
57 std::cout << m << sep;
58 msg += m+sep;
59 }
60 return msg;
61 }
62
63} }
void bind_engine(py::module &m, string name)
Defines a multi level static logger.
Definition logger.h:20
static void destroy()
Destroys the logger instance.
Definition logger.cpp:23
int get_log_level()
Gets the current log level.
Definition logger.cpp:44
static Logger * instance
The singleton instance of the logger.
Definition logger.h:57
void set_log_level(int &verbosity)
Sets the log level.
Definition logger.cpp:31
static Logger * initLogger()
Initializes the logger instance.
Definition logger.cpp:13
int verbosity
The current log level.
Definition logger.h:56
string log(string m, int v, string sep="\n") const
Prints a log message with verbosity control.
Definition logger.cpp:50
#define HANDLE_WARNING(err)
Definition error.h:28
< nsga2 selection operator for getting the front
Definition data.cpp:12