Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Logger.h
Go to the documentation of this file.
1 /*
2 * Copyright 2014-2018 Friedemann Zenke
3 *
4 * This file is part of Auryn, a simulation package for plastic
5 * spiking neural networks.
6 *
7 * Auryn is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Auryn is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Auryn. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * If you are using Auryn or parts of it for your work please cite:
21 * Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations
22 * of spiking neural networks using general-purpose computers.
23 * Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076
24 */
25 
26 #ifndef LOGGER_H_
27 #define LOGGER_H_
28 
29 #include <iostream>
30 #include <iomanip>
31 #include <fstream>
32 #include <sstream>
33 #include <string>
34 #include <time.h>
35 
36 #define AURYN_LOGGER_CERRLEVEL WARNING
37 
38 
39 namespace auryn {
42 
48 class Logger
49 {
50 private:
51  std::string fname;
52  std::ofstream outfile;
53  int local_rank;
54  LogMessageType console_out;
55  LogMessageType file_out;
56 
57  std::string last_message;
58 
59 
60 public:
61  Logger(std::string filename, int rank, LogMessageType console = PROGRESS, LogMessageType file = NOTIFICATION );
62  virtual ~Logger();
63 
64  void msg( std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="" );
65  void info ( std::string text );
66  void progress( std::string text );
67  void warning ( std::string text );
68  void error ( std::string text );
69  void verbose ( std::string text, bool global=false, int line=-1, std::string srcfile="" );
70  void debug ( std::string text, bool global=false, int line=-1, std::string srcfile="" );
71  void notification ( std::string text );
72  void set_rank(int rank);
73 
75  void set_debugging_mode();
76 
82 
88 
89  template<typename T>
90  void parameter(std::string name, T value)
91  {
92  std::stringstream oss;
93  oss << std::scientific << " Parameter " << name << "=" << value;
94  msg(oss.str(),SETTINGS,true);
95  }
96 };
97 
98 }
99 
100 #endif /*LOGGER_H_*/
void progress(std::string text)
Definition: Logger.cpp:121
void notification(std::string text)
Definition: Logger.cpp:131
void set_logfile_loglevel(LogMessageType level=NOTIFICATION)
Sets loglevel for file output.
Definition: Logger.cpp:63
void parameter(std::string name, T value)
Definition: Logger.h:90
virtual ~Logger()
Definition: Logger.cpp:50
Definition: Logger.h:41
Definition: Logger.h:41
void warning(std::string text)
Definition: Logger.cpp:136
Definition: Logger.h:41
void set_console_loglevel(LogMessageType level=PROGRESS)
Sets loglevel for console output.
Definition: Logger.cpp:58
void info(std::string text)
Definition: Logger.cpp:126
Definition: ABSConnection.h:38
A generic logger class that logs to screen and a log-file.
Definition: Logger.h:48
Definition: Logger.h:41
Logger(std::string filename, int rank, LogMessageType console=PROGRESS, LogMessageType file=NOTIFICATION)
Definition: Logger.cpp:31
void verbose(std::string text, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:146
Definition: Logger.h:41
void set_rank(int rank)
Definition: Logger.cpp:156
void error(std::string text)
Definition: Logger.cpp:141
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
LogMessageType
Enum type for significance level of a given message send to the Logger.
Definition: Logger.h:41
Definition: Logger.h:41
Definition: Logger.h:41
void debug(std::string text, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:151
void set_debugging_mode()
Turns on verbosity on all channels.
Definition: Logger.cpp:68
Definition: Logger.h:41
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156