From 46836a2d5feca184f71e3cfc4d1da60792f0eb35 Mon Sep 17 00:00:00 2001 From: amass <168062547@qq.com> Date: Wed, 27 Dec 2023 21:49:33 +0800 Subject: [PATCH] export log formatter. --- .gitignore | 44 ++++++++++++++++++++++++++++++++++++++++++ Universal/BoostLog.cpp | 13 ++++++------- Universal/BoostLog.h | 2 ++ resource/deploy.sh | 2 +- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .gitignore mode change 100644 => 100755 resource/deploy.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72c48ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +*.qmlc +*.jsc +Makefile* +*build-* + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +build \ No newline at end of file diff --git a/Universal/BoostLog.cpp b/Universal/BoostLog.cpp index cd5e93e..82da5fc 100644 --- a/Universal/BoostLog.cpp +++ b/Universal/BoostLog.cpp @@ -7,12 +7,10 @@ #include "AndroidBoostLog.h" #endif -static void logFormatter(boost::log::record_view const &record, boost::log::formatting_ostream &ostream); - BOOST_LOG_GLOBAL_LOGGER_INIT(location_logger, LocationLogger) { LocationLogger lg; auto consoleSink = boost::log::add_console_log(); - consoleSink->set_formatter(&logFormatter); + consoleSink->set_formatter(&boost::log::defaultFormatter); boost::log::add_common_attributes(); return lg; } @@ -35,15 +33,13 @@ void initialize(const std::string &filename, const std::string &target, boost::l oss << filename << "_%Y-%m-%d_%H.%M.%S_%N.log"; auto fileSink = add_file_log(keywords::file_name = oss.str(), keywords::auto_flush = true, keywords::target = target); - fileSink->set_formatter(&logFormatter); + fileSink->set_formatter(&defaultFormatter); #endif initialized = true; } } -} // namespace log -} // namespace boost -static void logFormatter(const boost::log::record_view &record, boost::log::formatting_ostream &ostream) { +void defaultFormatter(const boost::log::record_view &record, boost::log::formatting_ostream &ostream) { using namespace boost::log; std::string level; @@ -70,3 +66,6 @@ static void logFormatter(const boost::log::record_view &record, boost::log::form // Finally, put the record message to the stream ostream << record[expressions::smessage]; } + +} // namespace log +} // namespace boost diff --git a/Universal/BoostLog.h b/Universal/BoostLog.h index 6f1575e..3e28f37 100644 --- a/Universal/BoostLog.h +++ b/Universal/BoostLog.h @@ -64,6 +64,8 @@ namespace log { */ void initialize(const std::string &filename = "logs/app", const std::string &target = "logs", trivial::severity_level filter = static_cast(LOG_FILTER_LEVEL)); + +void defaultFormatter(boost::log::record_view const &record, boost::log::formatting_ostream &ostream); } // namespace log } // namespace boost diff --git a/resource/deploy.sh b/resource/deploy.sh old mode 100644 new mode 100755 index 5bf71f6..304e089 --- a/resource/deploy.sh +++ b/resource/deploy.sh @@ -3,7 +3,7 @@ base_path=$(pwd) qt_prefix_path="/opt/Qt/6.6.1/gcc_64" libraries_root="/opt/Libraries" -if [ $base_path == /home/* ] || [ -n "${DRONE}" ]; then +if [ $base_path==/home/* ]; then build_path=${base_path}/build else build_path=/tmp/build