Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
formatter.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_FORMATTER_H_)
21 #define __MITSUBA_CORE_FORMATTER_H_
22 
23 #include <mitsuba/mitsuba.h>
24 
26 
27 /// Available Log message types
28 enum ELogLevel {
29  ETrace = 0, ///< Trace message, for extremely verbose debugging
30  EDebug = 100, ///< Debug message, usually turned off
31  EInfo = 200, ///< More relevant debug / information message
32  EWarn = 300, ///< Warning message
33  EError = 400 ///< Error message, causes an exception to be thrown
34 };
35 
36 /** \brief Abstract interface for converting log information into
37  * a human-readable format
38  *
39  * \ingroup libcore
40  * \ingroup libpython
41  */
43 public:
44  /**
45  * \brief Turn a log message into a human-readable format
46  * \param logLevel The importance of the debug message
47  * \param theClass Originating class or NULL
48  * \param thread Thread, which is reponsible for creating the message
49  * \param text Text content associated with the log message
50  * \param file File, which is responsible for creating the message
51  * \param line Associated line within the source file
52  */
53 
54  virtual std::string format(ELogLevel logLevel, const Class *theClass,
55  const Thread *thread, const std::string &text,
56  const char *file, int line) = 0;
57 
59 protected:
60  /// Virtual destructor
61  virtual ~Formatter() { }
62 };
63 
64 /** \brief The default formatter used to turn log messages into
65  * a human-readable form
66  * \ingroup libcore
67  * \ingroup libpython
68  */
70  friend class Logger;
71 public:
72  /// Create a new default formatter
74 
75  std::string format(ELogLevel logLevel, const Class *theClass,
76  const Thread *thread, const std::string &text,
77  const char *file, int line);
78 
79  /// Should date information be included? The default is yes.
80  inline void setHaveDate(bool value) { m_haveDate = value; }
81 
82  /// Should thread information be included? The default is yes.
83  inline void setHaveThread(bool value) { m_haveThread = value; }
84 
85  /// Should log level information be included? The default is yes.
86  inline void setHaveLogLevel(bool value) { m_haveLogLevel = value; }
87 
88  /// Should class information be included? The default is yes.
89  inline void setHaveClass(bool value) { m_haveClass = value; }
90 
92 protected:
93  /// Virtual destructor
94  virtual ~DefaultFormatter() { }
95 protected:
96  bool m_haveDate;
100 };
101 
103 
104 #endif /* __MITSUBA_CORE_FORMATTER_H_ */
bool m_haveLogLevel
Definition: formatter.h:97
Abstract interface for converting log information into a human-readable format.
Definition: formatter.h:42
Trace message, for extremely verbose debugging.
Definition: formatter.h:29
void setHaveClass(bool value)
Should class information be included? The default is yes.
Definition: formatter.h:89
bool m_haveClass
Definition: formatter.h:99
#define MTS_EXPORT_CORE
Definition: getopt.h:29
Debug message, usually turned off.
Definition: formatter.h:30
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
More relevant debug / information message.
Definition: formatter.h:31
void setHaveDate(bool value)
Should date information be included? The default is yes.
Definition: formatter.h:80
virtual std::string format(ELogLevel logLevel, const Class *theClass, const Thread *thread, const std::string &text, const char *file, int line)=0
Turn a log message into a human-readable format.
bool m_haveDate
Definition: formatter.h:96
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Warning message.
Definition: formatter.h:32
The default formatter used to turn log messages into a human-readable form.
Definition: formatter.h:69
Stores meta-information about Object instances.
Definition: class.h:43
Cross-platform thread implementation.
Definition: thread.h:34
void setHaveLogLevel(bool value)
Should log level information be included? The default is yes.
Definition: formatter.h:86
ELogLevel
Available Log message types.
Definition: formatter.h:28
void setHaveThread(bool value)
Should thread information be included? The default is yes.
Definition: formatter.h:83
Error message, causes an exception to be thrown.
Definition: formatter.h:33
Responsible for processing log messages.
Definition: logger.h:116
bool m_haveThread
Definition: formatter.h:98
Parent of all Mitsuba classes.
Definition: object.h:38
#define MTS_NAMESPACE_END
Definition: platform.h:138