TrueReality  v0.1.1912
LogLevel.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 Matthew W. Campbell
22 * @author Erik Johnson
23 * @author David Guthrie
24 * @author Maxim Serebrennik
25 */
26 
28 
29 namespace trUtil::Logging
30 {
32  LogLevel LogLevelFromString(const std::string& levelString)
33  {
34  if (levelString == LOG_ALWAYS_STR)
35  {
36  return LogLevel::LOG_ALWAYS;
37  }
38  else if (levelString == LOG_ERROR_STR)
39  {
40  return LogLevel::LOG_ERROR;
41  }
42  else if (levelString == LOG_WARNING_STR)
43  {
44  return LogLevel::LOG_WARNING;
45  }
46  else if (levelString == LOG_INFO_STR)
47  {
48  return LogLevel::LOG_INFO;
49  }
50  else if (levelString == LOG_DEBUG_STR)
51  {
52  return LogLevel::LOG_DEBUG;
53  }
54  else
55  {
56  return LogLevel::LOG_WARNING;
57  }
58  }
59 
61  const std::string& LogLevelToString(LogLevel logLevel)
62  {
63  switch (logLevel)
64  {
65  case LogLevel::LOG_ALWAYS: return LOG_ALWAYS_STR;
68  case LogLevel::LOG_INFO: return LOG_INFO_STR;
70  default: return LOG_WARNING_STR;
71  }
72  }
73 }
LOG_DEBUG
Definition: LogLevel.h:64
static const std::string LOG_ERROR_STR("Error")
String value for ERROR Logging level.
static const std::string LOG_WARNING_STR("Warning")
String value for WARNING Logging level.
static const std::string LOG_DEBUG_STR("Debug")
String value for DEBUG Logging level.
TR_UTIL_EXPORT LogLevel LogLevelFromString(const std::string &levelString)
Logs level from string.
Definition: LogLevel.cpp:32
static const std::string LOG_ALWAYS_STR("Always")
String value for ALWAYS Logging level.
LOG_ERROR
Definition: LogLevel.h:64
LOG_WARNING
Definition: LogLevel.h:64
static const std::string LOG_INFO_STR("Info")
String value for INFO Logging level.
LOG_INFO
Definition: LogLevel.h:64
const TR_UTIL_EXPORT std::string & LogLevelToString(LogLevel logLevel)
Logs level to string.
Definition: LogLevel.cpp:61