34 moodycamel::BlockingConcurrentQueue<Console::OutputEntry>&
OutBuffer()
36 NO_DESTROY static moodycamel::BlockingConcurrentQueue<Console::OutputEntry> s_OutputBuffer;
37 return s_OutputBuffer;
44 outStream <<
"[ " << std::internal
46 << std::setprecision(3)
58 outStream <<
"[ " << std::this_thread::get_id() <<
" ] ";
90 ._text = outStream.str().c_str(),
98 else if (!OutBuffer().enqueue(
entry))
111 outStream <<
entry._text.c_str();
134 count = OutBuffer().try_dequeue_bulk(std::begin(g_outputCache), g_outputCache.size());
136 for (
size_t i = 0u; i < count; ++i)
140 }
while (count > 0u);
144void Console::Start(
const std::string_view logFilePath,
const std::string_view erroFilePath,
const bool printCopyright )
noexcept
147 s_running.store(
true);
149 s_logStream = std::ofstream{ (Paths::g_logPath / logFilePath).fileSystemPath(), std::ofstream::out | std::ofstream::trunc };
150 s_errorStream = std::ofstream{ (Paths::g_logPath / erroFilePath).fileSystemPath(), std::ofstream::out | std::ofstream::trunc };
152 std::cout.rdbuf( s_logStream.rdbuf() );
153 std::cerr.rdbuf( s_errorStream.rdbuf() );
156 if ( printCopyright )
158 s_logStream <<
"------------------------------------------------------------------------------\n"
159 <<
"Copyright (c) 2018 DIVIDE-Studio\n"
160 <<
"Copyright (c) 2009 Ionut Cava\n\n"
161 <<
"This file is part of DIVIDE Framework.\n\n"
162 <<
"Permission is hereby granted, free of charge, to any person obtaining a copy of this software\n"
163 <<
"and associated documentation files (the 'Software'), to deal in the Software without restriction,\n"
164 <<
"including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,\n"
165 <<
"and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,\n"
166 <<
"subject to the following conditions:\n\n"
167 <<
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n"
168 <<
"THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n"
169 <<
"INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n"
170 <<
"IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n"
171 <<
"WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\n"
172 <<
"OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n"
173 <<
"For any problems or licensing issues I may have overlooked, please contact: \n"
174 <<
"E-mail: ionut.cava@divide-studio.com | Website: \n http://wwww.divide-studio.com\n"
175 <<
"-------------------------------------------------------------------------------\n\n";
181 bool expected =
true;
182 if (
s_running.compare_exchange_strong(expected,
false) )
186 s_logStream <<
"------------------------------------------\n\n\n\n";
189 std::cerr << std::flush;
190 std::cout << std::flush;
196 static size_t callbackId{ 0u };
200 entry._cbk = guiConsoleCallback;
201 entry._id = callbackId++;
213 return entry._id == index;
static U64 FrameCount() noexcept
D64 ElapsedSeconds() noexcept
NO_DESTROY std::array< Console::OutputEntry, 16 > g_outputCache
moodycamel::BlockingConcurrentQueue< Console::OutputEntry > & OutBuffer()
Handle console commands that start with a forward slash.
std::basic_stringstream< char, std::char_traits< char >, dvd_allocator< char > > stringstream
std::lock_guard< mutex > LockGuard
std::shared_mutex SharedMutex
std::shared_lock< mutex > SharedLock
constexpr U32 DEFAULT_FLAGS
Project const SceneEntry & entry
constexpr auto to_base(const Type value) -> Type
static std::ofstream s_errorStream
static std::atomic_bool s_running
static void DecorateAndPrint(std::ostream &outStream, std::string_view text, bool newline, EntryType type)
std::function< void(const OutputEntry &)> ConsolePrintCallback
static void PrintToFile(const OutputEntry &entry)
static vector< ConsolePrintCallbackEntry > s_guiConsoleCallbacks
static SharedMutex s_callbackLock
static void Output(std::string_view text, bool newline, EntryType type)
static bool IsFlagSet(const Flags flag)
static bool UnbindConsoleOutput(size_t &index)
static size_t BindConsoleOutput(const ConsolePrintCallback &guiConsoleCallback)
static void Start(std::string_view logFilePath, std::string_view erroFilePath, bool printCopyright) noexcept
static std::ofstream s_logStream