TexGen
Logger.h
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#pragma once
21namespace TexGen
22{
24
29 #define TGERROR(MESSAGE) \
30 { \
31 std::ostringstream o; \
32 o << MESSAGE; \
33 GetLogger().TexGenError(__FILE__, __LINE__, o.str()); \
34 }
35
36 #define TGLOG(MESSAGE) \
37 { \
38 std::ostringstream o; \
39 o << MESSAGE; \
40 GetLogger().TexGenLog(__FILE__, __LINE__, o.str()); \
41 }
42
44
55 #define TGLOGINCREASEINDENT() \
56 { \
57 GetLogger().IncreaseIndent(); \
58 }
59
60 #define TGLOGDECREASEINDENT() \
61 { \
62 GetLogger().DecreaseIndent(); \
63 }
64
65 #define TGLOGAUTOINDENT() CLogIndent AutoLogIndentVariable;
66
68 #define TGLOGINDENT(MESSAGE) TGLOG(MESSAGE) TGLOGAUTOINDENT()
69
71
77 {
78 public:
79 CLogIndent();
81 };
82
85 {
86 public:
87 CLogger(void);
88 virtual ~CLogger(void);
89
90 virtual CLogger *Copy() const = 0;
91 virtual void TexGenError(std::string FileName, int iLineNumber, std::string Message) = 0;
92 virtual void TexGenLog(std::string FileName, int iLineNumber, std::string Message) = 0;
93 void IncreaseIndent() { ++m_iIndent; }
94 void DecreaseIndent() { if (m_iIndent>0) --m_iIndent; }
95
96 protected:
98 };
99
102 {
103 public:
104 CLogger *Copy() const { return new CLoggerScreen(*this); }
105 void TexGenError(std::string FileName, int iLineNumber, std::string Message);
106 void TexGenLog(std::string FileName, int iLineNumber, std::string Message);
107
108 protected:
109 };
110
113 {
114 public:
115 CLogger *Copy() const { return new CLoggerNull(*this); }
116 void TexGenError(std::string FileName, int iLineNumber, std::string Message) {;}
117 void TexGenLog(std::string FileName, int iLineNumber, std::string Message) {;}
118
119 protected:
120 };
121
122 CLASS_DECLSPEC CLogger &GetLogger();
123}; // namespace TexGen
124
125
126
127
128
129
130
#define CLASS_DECLSPEC
Definition: Misc.h:35
Class to handle log indenting.
Definition: Logger.h:77
Abstract base class to act as an interface between texgen and the logger.
Definition: Logger.h:85
virtual CLogger * Copy() const =0
void DecreaseIndent()
Definition: Logger.h:94
virtual void TexGenLog(std::string FileName, int iLineNumber, std::string Message)=0
int m_iIndent
Definition: Logger.h:97
void IncreaseIndent()
Definition: Logger.h:93
virtual void TexGenError(std::string FileName, int iLineNumber, std::string Message)=0
Logger used to send all log and error messages into a black hole.
Definition: Logger.h:113
void TexGenError(std::string FileName, int iLineNumber, std::string Message)
Definition: Logger.h:116
CLogger * Copy() const
Definition: Logger.h:115
void TexGenLog(std::string FileName, int iLineNumber, std::string Message)
Definition: Logger.h:117
Logger used to print all log and error messages to the screen.
Definition: Logger.h:102
CLogger * Copy() const
Definition: Logger.h:104
Namespace containing a series of customised math operations not found in the standard c++ library.
CLogger & GetLogger()
Definition: Logger.cpp:63