update logging to create parent directory if it does not exist
This commit is contained in:
parent
d3a49c9f0f
commit
fd00bddcb4
2 changed files with 8 additions and 2 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@
|
||||||
#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 {
|
||||||
class file_appender::impl : public fc::retainable {
|
class file_appender::impl : public fc::retainable {
|
||||||
public:
|
public:
|
||||||
config cfg;
|
config cfg;
|
||||||
ofstream out;
|
ofstream out;
|
||||||
boost::mutex slock;
|
boost::mutex slock;
|
||||||
};
|
};
|
||||||
file_appender::config::config( const fc::path& p )
|
file_appender::config::config( const fc::path& p )
|
||||||
|
|
@ -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() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue