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( 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<fc::string> ostring;
class variant_object;

View file

@ -7,13 +7,14 @@
#include <fc/reflect/variant.hpp>
#include <iomanip>
#include <sstream>
#include <fc/filesystem.hpp>
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<config>();
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() );
}
}