Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Logger.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
45 #ifndef __LOGGER_H__
46 #define __LOGGER_H__
47 
48 #include <string>
49 #include "CoreConfig.h"
50 #include <fstream>
51 
52 namespace Menge {
53 
55 
59  class Logger {
60  public:
65  enum LogType {
70  };
71 
75  MENGE_API Logger();
76 
80  MENGE_API ~Logger();
81 
85  MENGE_API void close();
86 
90  MENGE_API void line();
91 
100  MENGE_API void setFile( const std::string & fileName );
101 
109  friend MENGE_API Logger & operator<<( Logger & logger, const std::string & msg );
110 
118  friend MENGE_API Logger & operator<<( Logger & logger, const char * msg );
119 
120 
128  friend MENGE_API Logger & operator<<( Logger & logger, long unsigned int value );
129 
130  #if defined(_MSC_VER)
131 
138  friend MENGE_API Logger & operator<<( Logger & logger, size_t value );
139  #endif
140 
148  friend MENGE_API Logger & operator<<( Logger & logger, unsigned int value );
149 
157  friend MENGE_API Logger & operator<<( Logger & logger, int value );
158 
166  friend MENGE_API Logger & operator<<( Logger & logger, float value );
167 
175  friend MENGE_API Logger & operator<<( Logger & logger, double value );
176 
184  friend MENGE_API Logger & operator<<( Logger & logger, Logger::LogType type );
185 
186  protected:
190  void writeHeader();
191 
195  void writeTail();
196 
205  void processText( std::string & input );
206 
211 
215  std::ofstream _file;
216 
221  };
222 
223 
230  extern MENGE_API Logger logger;
231 
232 } // namespace Menge
233 
234 #endif // __LOGGER_H__
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
Error encountered and handled.
Definition: Logger.h:68
Sets up the proper compiler directives for platform and dll export/import.
MENGE_API void close()
Closes the logger down.
Definition: Logger.cpp:128
LogType
Classfies interpretation of the subsequent streaming elements.
Definition: Logger.h:65
MENGE_API ~Logger()
Destructor.
Definition: Logger.cpp:122
An html logger - writes messages to a formatted html file.
Definition: Logger.h:59
bool _validFile
Indicates if the output file is valid.
Definition: Logger.h:210
void writeHeader()
Writes the html header information to the given file.
Definition: Logger.cpp:168
std::ofstream _file
The file object for the html to be written to.
Definition: Logger.h:215
void processText(std::string &input)
Process text.
Definition: Logger.cpp:218
Benign information - reports status.
Definition: Logger.h:67
LogType _streamType
The current message type.
Definition: Logger.h:220
Logger logger
Globally available Logger.
Definition: Logger.cpp:49
MENGE_API Logger()
Default constructor.
Definition: Logger.cpp:53
MENGE_API void setFile(const std::string &fileName)
Sets the logger's output file.
Definition: Logger.cpp:155
void writeTail()
Writes the html tail information to the given file.
Definition: Logger.cpp:187
friend MENGE_API Logger & operator<<(Logger &logger, const std::string &msg)
Writes strings to the logger based on current status.
Definition: Logger.cpp:232
Error encountered but not handled.
Definition: Logger.h:69
No interpretation provided.
Definition: Logger.h:66
MENGE_API void line()
Writes a solid line to the logger.
Definition: Logger.cpp:138