diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-09-26 00:24:22 +0200 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2015-10-05 17:11:57 +0200 |
commit | 0cf04cc166e4bd79c1e1f5ceb636d31bf8af560a (patch) | |
tree | 6b931eb13c39682d2c883216b5ad4a1ac0fa338c /src/server/database/Updater/DBUpdater.cpp | |
parent | 5b8f1469ca32ff1b02b8f902954e1ffc362c4343 (diff) |
Core/Updater: Pipe mysql process output into worldserver log
(cherry picked from commit 2d109b63e2f1d03a961dd58947598f73e4e43ba0)
Diffstat (limited to 'src/server/database/Updater/DBUpdater.cpp')
-rw-r--r-- | src/server/database/Updater/DBUpdater.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index ebdd6604fef..c9056e12361 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -26,6 +26,8 @@ #include <iostream> #include <unordered_map> #include <boost/process.hpp> +#include <boost/iostreams/stream.hpp> +#include <boost/iostreams/copy.hpp> #include <boost/iostreams/device/file_descriptor.hpp> #include <boost/system/system_error.hpp> @@ -391,9 +393,29 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos uint32 ret; try { + boost::process::pipe outPipe = create_pipe(); + boost::process::pipe errPipe = create_pipe(); + child c = execute(run_exe(DBUpdater<T>::GetMySqlCli().empty() ? "mysql" : boost::filesystem::absolute(DBUpdater<T>::GetMySqlCli()).generic_string()), - set_args(args), bind_stdin(source), throw_on_error()); + set_args(args), bind_stdin(source), throw_on_error(), + bind_stdout(file_descriptor_sink(outPipe.sink, close_handle)), + bind_stderr(file_descriptor_sink(errPipe.sink, close_handle))); + + file_descriptor_source mysqlOutfd(outPipe.source, close_handle); + file_descriptor_source mysqlErrfd(errPipe.source, close_handle); + + stream<file_descriptor_source> mysqlOutStream(mysqlOutfd); + stream<file_descriptor_source> mysqlErrStream(mysqlErrfd); + + std::stringstream out; + std::stringstream err; + + copy(mysqlOutStream, out); + copy(mysqlErrStream, err); + + TC_LOG_INFO("sql.updates", "%s", out.str().c_str()); + TC_LOG_ERROR("sql.updates", "%s", err.str().c_str()); ret = wait_for_exit(c); } |