GteLogger.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
9 #include <LowLevel/GteLogger.h>
10 using namespace gte;
11 
12 
13 Logger::Logger(char const* file, char const* function, int line,
14  std::string const& message)
15 {
16  mMessage =
17  "File: " + std::string(file) + "\n" +
18  "Func: " + std::string(function) + "\n" +
19  "Line: " + std::to_string(line) + "\n" +
20  message + "\n\n";
21 }
22 
24 {
25  msMutex.lock();
26  for (auto listener : msListeners)
27  {
28  if (listener->GetFlags() & Listener::LISTEN_FOR_ASSERTION)
29  {
30  listener->Assertion(mMessage);
31  }
32  }
33  msMutex.unlock();
34 }
35 
37 {
38  msMutex.lock();
39  for (auto listener : msListeners)
40  {
41  if (listener->GetFlags() & Listener::LISTEN_FOR_ERROR)
42  {
43  listener->Error(mMessage);
44  }
45  }
46  msMutex.unlock();
47 }
48 
50 {
51  msMutex.lock();
52  for (auto listener : msListeners)
53  {
54  if (listener->GetFlags() & Listener::LISTEN_FOR_WARNING)
55  {
56  listener->Warning(mMessage);
57  }
58  }
59  msMutex.unlock();
60 }
61 
63 {
64  msMutex.lock();
65  for (auto listener : msListeners)
66  {
67  if (listener->GetFlags() & Listener::LISTEN_FOR_INFORMATION)
68  {
69  listener->Information(mMessage);
70  }
71  }
72  msMutex.unlock();
73 }
74 
75 void Logger::Subscribe(Listener* listener)
76 {
77  msMutex.lock();
78  msListeners.insert(listener);
79  msMutex.unlock();
80 }
81 
83 {
84  msMutex.lock();
85  msListeners.erase(listener);
86  msMutex.unlock();
87 }
88 
89 
90 
91 // Logger::Listener
92 
94 {
95 }
96 
98  :
99  mFlags(flags)
100 {
101 }
102 
104 {
105  return mFlags;
106 }
107 
109 {
110  Report("\nGTE ASSERTION:\n" + message);
111 }
112 
114 {
115  Report("\nGTE ERROR:\n" + message);
116 }
117 
119 {
120  Report("\nGTE WARNING:\n" + message);
121 }
122 
124 {
125  Report("\nGTE INFORMATION:\n" + message);
126 }
127 
129 {
130  // Stub for derived classes.
131 }
132 
133 
134 std::mutex Logger::msMutex;
135 std::set<Logger::Listener*> Logger::msListeners;
void Warning(std::string const &message)
Definition: GteLogger.cpp:118
void Warning()
Definition: GteLogger.cpp:49
Listener(int flags=LISTEN_FOR_NOTHING)
Definition: GteLogger.cpp:97
static std::mutex msMutex
Definition: GteLogger.h:77
void Error(std::string const &message)
Definition: GteLogger.cpp:113
void Assertion()
Definition: GteLogger.cpp:23
void Information()
Definition: GteLogger.cpp:62
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
static void Subscribe(Listener *listener)
Definition: GteLogger.cpp:75
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2538
void Information(std::string const &message)
Definition: GteLogger.cpp:123
GLbitfield flags
Definition: glcorearb.h:1591
std::string mMessage
Definition: GteLogger.h:75
static std::set< Listener * > msListeners
Definition: GteLogger.h:78
static void Unsubscribe(Listener *listener)
Definition: GteLogger.cpp:82
virtual void Report(std::string const &message)
Definition: GteLogger.cpp:128
int GetFlags() const
Definition: GteLogger.cpp:103
void Error()
Definition: GteLogger.cpp:36
Logger(char const *file, char const *function, int line, std::string const &message)
Definition: GteLogger.cpp:13
void Assertion(std::string const &message)
Definition: GteLogger.cpp:108


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00