From f20cf1b92f2e48e3403db6ef58eb564eea71558d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 1 Oct 2007 08:36:15 +0000 Subject: [PATCH] fixes issue whith failure to create logs causes libtorrent to quit, fixes ticket #168 --- include/libtorrent/debug.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/debug.hpp b/include/libtorrent/debug.hpp index 1bb645a8e..41e08b28d 100755 --- a/include/libtorrent/debug.hpp +++ b/include/libtorrent/debug.hpp @@ -60,10 +60,17 @@ namespace libtorrent { logger(fs::path const& filename, int instance, bool append = true) { - fs::path dir(fs::complete("libtorrent_logs" + boost::lexical_cast(instance))); - if (!fs::exists(dir)) fs::create_directories(dir); - m_file.open((dir / filename).string().c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::out)); - *this << "\n\n\n*** starting log ***\n"; + try + { + fs::path dir(fs::complete("libtorrent_logs" + boost::lexical_cast(instance))); + if (!fs::exists(dir)) fs::create_directories(dir); + m_file.open((dir / filename).string().c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::out)); + *this << "\n\n\n*** starting log ***\n"; + } + catch (std::exception& e) + { + std::cerr << "failed to create log '" << filename << "': " << e.what() << std::endl; + } } template