diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-09-26 00:24:22 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2015-09-26 00:24:22 +0200 |
commit | 2d109b63e2f1d03a961dd58947598f73e4e43ba0 (patch) | |
tree | 427f72e38da9365b6050564588c9d16d539dab12 /src | |
parent | d71e0660fbfc6947972368065555752a3f8990c5 (diff) |
Core/Updater: Pipe mysql process output into worldserver log
Diffstat (limited to 'src')
-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 c0dfd400efc..c3f3578889b 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> @@ -423,9 +425,29 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos uint32 ret; try { + pipe outPipe = create_pipe(); + 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); } |