Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengtuggy committed Apr 25, 2024
1 parent 379f82e commit 2b21258
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 53 deletions.
6 changes: 4 additions & 2 deletions engine/src/audio/renderers/OpenAL/OpenALRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2001-2022 Daniel Horn, pyramid3d, Stephen G. Tuggy,
* OpenALRenderer.cpp
*
* Copyright (C) 2001-2024 Daniel Horn, pyramid3d, Stephen G. Tuggy,
* and other Vega Strike contributors.
*
* https://github.com/vegastrike/Vega-Strike-Engine-Source
Expand All @@ -13,7 +15,7 @@
*
* Vega Strike is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
Expand Down
53 changes: 3 additions & 50 deletions engine/src/vs_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@
#include <string>
#include <cstdint>

#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/sinks/async_frontend.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/utility/setup/console.hpp>
Expand All @@ -46,13 +43,6 @@

namespace VegaStrikeLogging {

// void exitProgram(int code)
// {
// Music::CleanupMuzak();
// VegaStrikeLogging::VegaStrikeLogger::instance().FlushLogs();
// winsys_exit(code);
// }

void VegaStrikeLogger::InitLoggingPart2(const uint8_t debug_level,
const boost::filesystem::path &vega_strike_home_dir) {

Expand All @@ -76,7 +66,7 @@ void VegaStrikeLogger::InitLoggingPart2(const uint8_t debug_level,
break;
}

file_log_back_end_ = boost::make_shared<FileLogBackEnd>
file_log_sink_ = boost::log::add_file_log
(
boost::log::keywords::file_name =
logging_dir_name + "/" + "vegastrike_%Y-%m-%d_%H_%M_%S.%f.log", /*< file name pattern >*/
Expand All @@ -91,23 +81,12 @@ void VegaStrikeLogger::InitLoggingPart2(const uint8_t debug_level,
boost::log::keywords::min_free_space = 5UL * 1024UL * 1024UL
* 1024UL /*< stop boost::log when there's only 5 GiB free space left >*/
);
file_log_sink_ = boost::make_shared<FileLogSink>(file_log_back_end_);
logging_core_->add_sink(file_log_sink_);

console_log_sink_->set_filter(severity >= important_info);
}

void VegaStrikeLogger::FlushLogs() {
logging_core_->flush();
// if (console_log_sink_) {
//// console_log_sink_->feed_records();
// console_log_sink_->flush();
// }
// if (file_log_sink_) {
//// file_log_sink_->feed_records();
// file_log_sink_->flush();
// }

std::cout << std::flush;
std::cerr << std::flush;
std::clog << std::flush;
Expand All @@ -117,33 +96,11 @@ void VegaStrikeLogger::FlushLogs() {

void VegaStrikeLogger::FlushLogsProgramExiting() {
logging_core_->flush();
// if (console_log_sink_) {
// logging_core_->remove_sink(console_log_sink_);
//// console_log_sink_->stop();
// console_log_sink_->flush();
// }
// if (console_log_back_end_) {
// console_log_back_end_->flush();
// }
// if (file_log_sink_) {
// logging_core_->remove_sink(file_log_sink_);
//// file_log_sink_->stop();
// file_log_sink_->flush();
// }
// if (file_log_back_end_) {
// file_log_back_end_->flush();
// }

std::cout << std::flush;
std::cerr << std::flush;
std::clog << std::flush;
fflush(stdout);
fflush(stderr);

// console_log_sink_.reset();
// file_log_sink_.reset();
// console_log_back_end_.reset();
// file_log_back_end_.reset();
}

BOOST_LOG_GLOBAL_LOGGER_INIT(my_logger, severity_logger_mt<vega_log_level>) {
Expand All @@ -155,18 +112,14 @@ BOOST_LOG_GLOBAL_LOGGER_INIT(my_logger, severity_logger_mt<vega_log_level>) {
VegaStrikeLogger::VegaStrikeLogger() : slg_(my_logger::get()), file_log_back_end_(nullptr), file_log_sink_(nullptr) {
boost::filesystem::path::imbue(std::locale(""));
logging_core_ = boost::log::core::get();
// slg_ = my_logger::get();

console_log_back_end_ = boost::make_shared<ConsoleLogBackEnd>
console_log_sink_ = boost::log::add_console_log
(
boost::shared_ptr<std::ostream>(&std::cerr, boost::null_deleter()),
std::cerr,
boost::log::keywords::format =
"%Message%", /*< log record format specific to the console >*/
boost::log::keywords::auto_flush =
true /*false*/ /*< whether to do the equivalent of fflush(stdout) after every msg >*/
);
console_log_sink_ = boost::make_shared<ConsoleLogSink>(console_log_back_end_);
logging_core_->add_sink(console_log_sink_);
}

VegaStrikeLogger::~VegaStrikeLogger() {
Expand Down
1 change: 0 additions & 1 deletion engine/src/vs_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/format.hpp>
#include <boost/log/sources/global_logger_storage.hpp>
//#include <boost/log/sources/logger.hpp>
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sources/severity_logger.hpp>
Expand Down

0 comments on commit 2b21258

Please sign in to comment.