NGL  6.5
The NCCA Graphics Library
Logger.h
Go to the documentation of this file.
1 #ifndef LOGGER_H_
2 #define LOGGER_H_
3 #include "Types.h"
4 #include "Singleton.h"
5 #include <memory>
6 #include <cstdarg>
7 #include <iostream>
8 #include <ostream>
9 #include <fstream>
10 #include <boost/iostreams/stream.hpp>
11 #include <boost/iostreams/tee.hpp>
12 
14 namespace ngl
15 {
17  enum class TimeFormat : char {TIME,TIMEDATE,TIMEDATEDAY};
18 
19  class NGL_DLLEXPORT Logger : public Singleton<Logger>
20  {
21  friend class Singleton<Logger>;
22 
23  public :
24 
25  void logMessage(const char* fmt, ...) noexcept;
26  void logError(const char* fmt, ...) noexcept;
27  void logWarning(const char* fmt, ...) noexcept;
28  void close() noexcept;
29  void enableLogToFile() noexcept;
30  void disableLogToFile() noexcept;
31  void enableLogToConsole() noexcept;
32  void disableLogToConsole() noexcept;
33  void enableLogToFileAndConsole() noexcept;
34  void disableLogToFileAndConsole() noexcept;
35  void setLogFile(const std::string &_fname) noexcept;
36  void setColour(Colours _c) noexcept;
37  void enableLineNumbers() noexcept;
38  void disableLineNumbers() noexcept;
39  void enableTimeStamp() noexcept;
40  void disableTimeStamp() noexcept;
41  void disableColours() noexcept;
42  void enableColours() noexcept;
43  void setLineNumberPad(unsigned int i) noexcept;
44  void setTimeFormat(TimeFormat _f) noexcept;
45  typedef boost::iostreams::tee_device<std::ostream, std::ofstream > Tee;
46  typedef boost::iostreams::stream<Tee> TeeStream;
47  boost::iostreams::stream<Logger::Tee> &cout() noexcept;
48 
49  private :
50  Logger() noexcept;
51  Logger(const std::string &_fname) noexcept;
52  ~Logger();
53 
54  class Impl;
55  std::unique_ptr<Impl> m_impl;
56 
57 
58  };
59 
60 } // end namespace
61 
62 #endif
main definition of types and namespace
#define NGL_DLLEXPORT
Definition: Types.h:65
boost::iostreams::tee_device< std::ostream, std::ofstream > Tee
Definition: Logger.h:45
Definition: format.h:316
TimeFormat
Definition: Logger.h:17
boost::iostreams::stream< Tee > TeeStream
Definition: Logger.h:46
implementation files for RibExport class
Definition: AABB.cpp:22
GLuint GLuint stream
Definition: glew.h:7293
Colours
Definition: Logger.h:16
a simple singleton template inherited by other classes
Definition: format.cc:82
Singleton template added to NGL framework 20/04/10 by jmacey.
Definition: Singleton.h:40