From 0cf04cc166e4bd79c1e1f5ceb636d31bf8af560a Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 26 Sep 2015 00:24:22 +0200 Subject: Core/Updater: Pipe mysql process output into worldserver log (cherry picked from commit 2d109b63e2f1d03a961dd58947598f73e4e43ba0) --- src/server/database/Updater/DBUpdater.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/server/database/Updater/DBUpdater.cpp') 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 #include #include +#include +#include #include #include @@ -391,9 +393,29 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& 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::GetMySqlCli().empty() ? "mysql" : boost::filesystem::absolute(DBUpdater::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 mysqlOutStream(mysqlOutfd); + stream 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); } -- cgit v1.2.3