Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GRPH-2] Fixed log appending issue #3

Open
wants to merge 1 commit into
base: feature/ubuntu18.04-upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/fc/io/fstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
#include <fc/shared_ptr.hpp>
#include <fc/filesystem.hpp>
#include <fc/io/iostream.hpp>
#include <fstream>

namespace fc {
class path;
class ofstream : virtual public ostream {
public:
enum mode { out, binary };
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();

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 std::shared_ptr<const char>& buffer, size_t len, size_t offset);
void put( char c );
Expand Down
2 changes: 1 addition & 1 deletion src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace fc {
}
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();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/io/fstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace fc {
ofstream::ofstream()
: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 ); }
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;
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 ) {
my->ofs.write(buf,len);
Expand Down
7 changes: 2 additions & 5 deletions src/log/file_appender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace fc {
_compression_thread.reset( new thread( "compression") );
#endif

_rotation_task = async( [this]() { rotate_files( true ); }, "rotate_files(1)" );
_rotation_task = fc::async( [this]() { rotate_files( true ); }, "rotate_files(1)" );
}
}

Expand Down Expand Up @@ -112,10 +112,7 @@ namespace fc {
out.close();
}
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 );
else
out.open( log_filename, std::ios_base::out | std::ios_base::app);
out.open( log_filename, std::ios_base::out | std::ios_base::app );

create_hard_link(log_filename, link_filename);
}
Expand Down