From fd00bddcb4b057161e431a267e72ac1d79be13a6 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sat, 17 May 2014 16:38:32 -0400 Subject: [PATCH] update logging to create parent directory if it does not exist --- include/fc/string.hpp | 3 +++ src/log/file_appender.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/fc/string.hpp b/include/fc/string.hpp index 4ba03cd..889164a 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -16,6 +16,9 @@ namespace fc fc::string to_string( uint64_t ); fc::string to_string( int64_t ); fc::string to_string( uint16_t ); +#ifdef __APPLE__ + inline fc::string to_string( size_t s) { return to_string(uint64_t(s)); } +#endif typedef fc::optional ostring; class variant_object; diff --git a/src/log/file_appender.cpp b/src/log/file_appender.cpp index 35d27ca..9e2b979 100644 --- a/src/log/file_appender.cpp +++ b/src/log/file_appender.cpp @@ -7,13 +7,14 @@ #include #include #include +#include namespace fc { class file_appender::impl : public fc::retainable { public: - config cfg; - ofstream out; + config cfg; + ofstream out; boost::mutex slock; }; file_appender::config::config( const fc::path& p ) @@ -25,8 +26,10 @@ namespace fc { { try { my->cfg = args.as(); + fc::create_directories( fc::path( my->cfg.filename.string() ).parent_path() ); my->out.open( my->cfg.filename.string().c_str() ); } catch ( ... ) { + std::cerr << "error opening log file: " << my->cfg.filename.string() << "\n"; //elog( "%s", fc::except_str().c_str() ); } }