TrueReality  v0.1.1912
DefaultSettings.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 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 #include <trUtil/DefaultSettings.h>
22 
23 #include <trUtil/PathUtils.h>
24 #include <trUtil/PlatformMacros.h>
25 #include <trUtil/Logging/Log.h>
26 
27 #include <osg/ArgumentParser>
28 
29 
31 {
33  //void SetDefaultSettings(dtABC::BaseABC& app)
34  //{
35  // //Turn off the use of the default scene light
36  // app.GetScene()->UseSceneLight(false);
37  // app.GetScene()->UnRegisterLight(app.GetScene()->GetLight(0));
38 
39  // //Setting up camera options
40  // app.GetCamera()->SetNearFarCullingMode(dtCore::Camera::NO_AUTO_NEAR_FAR);
41 
42  // //Set the window name.
43  // app.GetWindow()->SetWindowTitle("True Reality");
44  //}
45 
47  void ParseMapNameArgument(int argc, char** argv, std::string &mapName)
48  {
49  osg::ArgumentParser arguments(&argc, argv);
50  arguments.read("--map", mapName);
51  }
52 
54  //void SetDefaultPaths()
55  //{
56  // //Setup data and file paths.
57  // std::string dataPath = trUtil::GetDataPathList();
58 
59  // trUtil::SetDataFilePathList(dataPath + ";" + trUtil::GetRootPath() + ";../" + ";./" + ";./Data"); //kept arround from D3D
60 
61  // //Setup data and file paths.
62  // //dataPath = trUtil::PathUtils::GetDataPath();
63  // //trUtil::PathUtils::SetDataFilePathList(dataPath + ";" + trUtil::PathUtils::GetRootPath() + ";../" + ";./" + ";./Data" + trUtil::GetDataFilePathList());
64 
65  // //Set the context path
66  // std::string context = "./Data";
67  // dtCore::Project::GetInstance().SetContext(context, true);
68  //}
69 
71  void SetupLoggingOptions(const std::string& logFileName, const std::string& logLevel)
72  {
73  //Set the Log file name.
74  if (!logFileName.empty())
75  {
77  }
78 
79  //Set the log level
80  if (logLevel.empty())
81  {
83  {
85  }
86  else
87  {
89  }
90  }
91  else
92  {
93  if (logLevel == trUtil::Logging::LOG_DEBUG_STR)
94  {
96  }
97  else if (logLevel == trUtil::Logging::LOG_INFO_STR)
98  {
100  }
101  else if (logLevel == trUtil::Logging::LOG_WARNING_STR)
102  {
104  }
105  else if (logLevel == trUtil::Logging::LOG_ERROR_STR)
106  {
108  }
109  else if (logLevel == trUtil::Logging::LOG_ALWAYS_STR)
110  {
111  trUtil::Logging::Log::GetInstance().SetAllLogLevels(trUtil::Logging::LogLevel::LOG_ALWAYS);
112  }
113  else
114  {
116  }
117  }
118 
119  //Set Log file options
121  {
123  }
124  else
125  {
127  }
128 
129  LOG_A("\n*\n*\nLOG Level is set to: '" + trUtil::Logging::Log::GetInstance().GetLogLevelString(trUtil::Logging::Log::GetInstance().GetLogLevel()) + "'\n*\n*\n");
130  }
131 }
LOG_DEBUG
Definition: LogLevel.h:64
static const std::string LOG_ERROR_STR("Error")
String value for ERROR Logging level.
static void SetFileName(const std::string &name)
Change the name of the log file (defaults to "TrueRealityLog.html")
Definition: LogFile.cpp:45
static void SetAllOutputStreamBits(unsigned int option)
The same as above, but it sets the bits on ALL active log instances.
Definition: Log.cpp:265
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.
static void SetAllLogLevels(LogLevel newLevel)
Set the LogLevel for all existing Log instances.
Definition: Log.cpp:304
static const std::string LOG_ALWAYS_STR("Always")
String value for ALWAYS Logging level.
DEBUG
const BuildType TR_BUILD_TYPE
Defines TR Build Types.
#define LOG_A(msg)
Log an ALWAYS message.
Definition: Log.h:174
LOG_ERROR
Definition: LogLevel.h:64
LOG_WARNING
Definition: LogLevel.h:64
void TR_UTIL_EXPORT SetupLoggingOptions(const std::string &logFileName, const std::string &logLevel)
Sets up all the default logging options for the software.
static const std::string LOG_INFO_STR("Info")
String value for INFO Logging level.
LOG_INFO
Definition: LogLevel.h:64
void TR_UTIL_EXPORT ParseMapNameArgument(int argc, char **argv, std::string &mapName)
Finds and returns the name of the map to be loaded from the command line.
static Log & GetInstance(const std::string &name=Log::LOG_DEFAULT_NAME)
Retrieve singleton instance of the log class for a give string name.
Definition: Log.cpp:203