TrueReality  v0.1.1912
LogWriterConsole.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * The Base of this class has been adopted from the Delta3D engine
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3.0 of the License, or (at your option)
10 * any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * @author Erik Johnson
22 * @author Maxim Serebrennik
23 */
24 
26 
28 
29 #include <iostream>
30 #include <iomanip>
31 
32 namespace trUtil::Logging
33 {
36  {
37  }
38 
41  {
42  }
43 
46  {
47  // Change the color of the text on the screen according to the Logging Level
48  switch (logData.logLevel)
49  {
52  break;
53 
56  break;
57 
60  break;
61 
64  break;
65 
66  case Logging::LogLevel::LOG_ALWAYS:
68  break;
69  }
70 
71 
72 
73  // Print out the time, the message, the log level, then where it came from
75 
76  if (logData.frameNumber > 0)
77  {
78  std::cerr << " Frm# " << logData.frameNumber;
79  }
80 
81  std::cerr << " " << trUtil::Logging::Log::GetLogLevelString(logData.logLevel) << "] ";
82 
83  std::cerr << logData.msg << " [";
84 
85  if (!logData.logName.empty())
86  {
87  std::cerr << "'" << logData.logName << "' ";
88  }
89 
90  if (!logData.method.empty())
91  {
92  std::cerr << logData.method << "()";
93  }
94 
95  if (!logData.file.empty())
96  {
97  std::cerr << " " << logData.file;
98 
99  if (logData.line > 0)
100  {
101  std::cerr << "(" << logData.line << ")";
102  }
103  }
104 
105  std::cerr << "]" << std::endl;
106 
107  //Change the color back to normal
109  }
110 }
std::string logName
The frame number.
Definition: LogWriter.h:75
LOG_DEBUG
Definition: LogLevel.h:64
std::string file
The name of the Log instance (could be empty)
Definition: LogWriter.h:76
BRIGHT_GREEN
Definition: TextColor.h:41
int line
The calling method of the message.
Definition: LogWriter.h:78
static const std::string GetLogLevelString(LogLevel logLevel)
Gets log level string.
Definition: Log.cpp:247
void TR_UTIL_EXPORT TextColor(TXT_COLOR TextColor)
Changes Text color in the console window....
Definition: TextColor.cpp:34
BRIGHT_YELLOW
Definition: TextColor.h:41
std::string method
The source file of the message.
Definition: LogWriter.h:77
DEFAULT
Definition: TextColor.h:41
virtual ~LogWriterConsole()
Destructor.
LOG_ERROR
Definition: LogLevel.h:64
std::string ToString() const
The no parameter version of ToString uses the internal TimeFormat, see the TimeFormat enumeration abo...
Definition: DateTime.cpp:577
LOG_WARNING
Definition: LogLevel.h:64
virtual void LogMessage(const LogData &logData)
Logs a message.
static const TimeFormat CLOCK_TIME_24_HOUR_FORMAT
CLOCK_TIME_24_HOUR_FORMAT: 13:22:50.
Definition: DateTime.h:158
LogWriterConsole()
Default constructor.
LOG_INFO
Definition: LogLevel.h:64
unsigned frameNumber
Time of message.
Definition: LogWriter.h:74
std::string msg
The line number of the source code of the message.
Definition: LogWriter.h:79
trUtil::DateTime time
Log level.
Definition: LogWriter.h:73
trUtil::Logging::LogLevel logLevel
Definition: LogWriter.h:70
BRIGHT_MAGENTA
Definition: TextColor.h:41
BRIGHT_RED
Definition: TextColor.h:41