Xmipp  v3.23.11-Nereus
xmipp_log.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: J.M. De la Rosa Trevin (jmdelarosa@cnb.csic.es)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program 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 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef CORE_LOG_H_
27 #define CORE_LOG_H_
28 
29 #include "xmipp_strings.h"
30 
34 class XmippLog
35 {
36 private:
37  String levelSpaces; //This variable will be used to set level spaces
38  /* File handler */
39  FILE * fileHandler;
40 
41 public:
42  /* Constructor */
43  XmippLog(String filename);
44  /* Destructor */
45  ~XmippLog();
46 
47  void logMessage(const String &msg);
48  /* Increase by 3 the level spaces */
49  void enterLevel(const String &msg="");
50  /* Decrease level spaces */
51  void leaveLevel(const String &msg="");
52 
53 };//class XmippLog
54 
60 {
61 private:
62  XmippLog * log;
63  String block;
64 
65 public:
66  /* Constructor */
67  XmippLogBlock(XmippLog * log, const String &block);
68  /* Destructor */
69  ~XmippLogBlock();
70 };//class XmippLogBlock
71 
73 extern XmippLog * __xmippLog;
74 
75 //#define LOG_ENABLED 1
76 
77 
78 #ifdef LOG_ENABLED
79 #define LOG_FN(root) formatString("%s_nodo%02d_debug.log", root.c_str(), rank)
80 #define CREATE_LOG(filename) __xmippLog = new XmippLog(filename)
81 #define LOG(msg) __xmippLog->logMessage(msg)
82 #define CLOSE_LOG() delete __xmippLog
83 #define LOG_LEVEL(var) XmippLogBlock __logBlock##var(__xmippLog, #var)
84 #define LOG_FUNCTION() XmippLogBlock __logBlock___function(__xmippLog, __FUNCTION__)
85 #else
86 #define CREATE_LOG(filename) ;
87 #define LOG(msg) ;
88 #define CLOSE_LOG() ;
89 #define LOG_LEVEL(msg) ;
90 #define LOG_FUNCTION() ;
91 #endif
92 
93 
94 #endif /* LOG_H_ */
void enterLevel(const String &msg="")
Definition: xmipp_log.cpp:51
void log(Image< double > &op)
XmippLog(String filename)
Definition: xmipp_log.cpp:34
std::string String
Definition: xmipp_strings.h:34
void leaveLevel(const String &msg="")
Definition: xmipp_log.cpp:57
XmippLog * __xmippLog
Definition: xmipp_log.cpp:32
void logMessage(const String &msg)
Definition: xmipp_log.cpp:44