update logging to create parent directory if it does not exist

This commit is contained in:
Daniel Larimer 2014-05-17 16:38:32 -04:00
parent d3a49c9f0f
commit fd00bddcb4
2 changed files with 8 additions and 2 deletions

View file

@ -16,6 +16,9 @@ namespace fc
fc::string to_string( uint64_t ); fc::string to_string( uint64_t );
fc::string to_string( int64_t ); fc::string to_string( int64_t );
fc::string to_string( uint16_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<fc::string> ostring; typedef fc::optional<fc::string> ostring;
class variant_object; class variant_object;

View file

@ -7,6 +7,7 @@
#include <fc/reflect/variant.hpp> #include <fc/reflect/variant.hpp>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <fc/filesystem.hpp>
namespace fc { namespace fc {
@ -25,8 +26,10 @@ namespace fc {
{ {
try { try {
my->cfg = args.as<config>(); my->cfg = args.as<config>();
fc::create_directories( fc::path( my->cfg.filename.string() ).parent_path() );
my->out.open( my->cfg.filename.string().c_str() ); my->out.open( my->cfg.filename.string().c_str() );
} catch ( ... ) { } catch ( ... ) {
std::cerr << "error opening log file: " << my->cfg.filename.string() << "\n";
//elog( "%s", fc::except_str().c_str() ); //elog( "%s", fc::except_str().c_str() );
} }
} }