[GRPH-2] Fixed log appending issue. #6
4 changed files with 9 additions and 11 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
#include <fc/shared_ptr.hpp>
|
#include <fc/shared_ptr.hpp>
|
||||||
#include <fc/filesystem.hpp>
|
#include <fc/filesystem.hpp>
|
||||||
#include <fc/io/iostream.hpp>
|
#include <fc/io/iostream.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
class path;
|
class path;
|
||||||
|
|
@ -9,10 +10,10 @@ namespace fc {
|
||||||
public:
|
public:
|
||||||
enum mode { out, binary };
|
enum mode { out, binary };
|
||||||
ofstream();
|
ofstream();
|
||||||
ofstream( const fc::path& file, int m = binary );
|
ofstream( const fc::path& file, std::ios_base::openmode m = std::ios_base::out | std::ios_base::binary );
|
||||||
~ofstream();
|
~ofstream();
|
||||||
|
|
||||||
void open( const fc::path& file, int m = binary );
|
void open( const fc::path& file, std::ios_base::openmode m = std::ios_base::out | std::ios_base::binary );
|
||||||
size_t writesome( const char* buf, size_t len );
|
size_t writesome( const char* buf, size_t len );
|
||||||
size_t writesome(const std::shared_ptr<const char>& buffer, size_t len, size_t offset);
|
size_t writesome(const std::shared_ptr<const char>& buffer, size_t len, size_t offset);
|
||||||
void put( char c );
|
void put( char c );
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ namespace fc {
|
||||||
}
|
}
|
||||||
if (create)
|
if (create)
|
||||||
{
|
{
|
||||||
fc::ofstream ofs(*_path, fc::ofstream::out | fc::ofstream::binary);
|
fc::ofstream ofs(*_path, std::ios_base::out | std::ios_base::binary);
|
||||||
ofs.close();
|
ofs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ namespace fc {
|
||||||
ofstream::ofstream()
|
ofstream::ofstream()
|
||||||
:my( new impl() ){}
|
:my( new impl() ){}
|
||||||
|
|
||||||
ofstream::ofstream( const fc::path& file, int m )
|
ofstream::ofstream( const fc::path& file, std::ios_base::openmode m )
|
||||||
:my( new impl() ) { this->open( file, m ); }
|
:my( new impl() ) { this->open( file, m ); }
|
||||||
ofstream::~ofstream(){}
|
ofstream::~ofstream(){}
|
||||||
|
|
||||||
void ofstream::open( const fc::path& file, int m ) {
|
void ofstream::open( const fc::path& file, std::ios_base::openmode m ) {
|
||||||
const boost::filesystem::path& bfp = file;
|
const boost::filesystem::path& bfp = file;
|
||||||
my->ofs.open( bfp, std::ios::binary );
|
my->ofs.open( bfp, std::ios_base::out | std::ios_base::binary | m );
|
||||||
}
|
}
|
||||||
size_t ofstream::writesome( const char* buf, size_t len ) {
|
size_t ofstream::writesome( const char* buf, size_t len ) {
|
||||||
my->ofs.write(buf,len);
|
my->ofs.write(buf,len);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ namespace fc {
|
||||||
_compression_thread.reset( new thread( "compression") );
|
_compression_thread.reset( new thread( "compression") );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_rotation_task = async( [this]() { rotate_files( true ); }, "rotate_files(1)" );
|
_rotation_task = fc::async( [this]() { rotate_files( true ); }, "rotate_files(1)" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,10 +112,7 @@ namespace fc {
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
remove_all(link_filename); // on windows, you can't delete the link while the underlying file is opened for writing
|
remove_all(link_filename); // on windows, you can't delete the link while the underlying file is opened for writing
|
||||||
if( fc::exists( log_filename ) )
|
out.open( log_filename, std::ios_base::out | std::ios_base::app );
|
||||||
out.open( log_filename, std::ios_base::out | std::ios_base::app );
|
|
||||||
else
|
|
||||||
out.open( log_filename, std::ios_base::out | std::ios_base::app);
|
|
||||||
|
|
||||||
create_hard_link(log_filename, link_filename);
|
create_hard_link(log_filename, link_filename);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue