Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Allow saving list_errors output to file
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramrajkumar committed Jun 24, 2014
1 parent 22c273c commit b01e329
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libraries/api/general_api.json
Expand Up @@ -178,6 +178,12 @@
"description" : "the maximum number of errors to return",
"type" : "uint32_t",
"default_value" : "20"
},
{
"name" : "filename",
"type" : "string",
"description" : "the filename to save json error list to",
"default_value" : ""
}
],
"is_const" : true,
Expand Down
1 change: 1 addition & 0 deletions libraries/blockchain/chain_database.cpp
Expand Up @@ -1735,6 +1735,7 @@ namespace bts { namespace blockchain {
if( filename == "" )
return out.str();

FC_ASSERT( !fc::exists( fc::path( filename ) ) );
std::ofstream fileout( filename.generic_string().c_str() );
fileout << out.str();

Expand Down
11 changes: 10 additions & 1 deletion libraries/client/client.cpp
Expand Up @@ -2523,7 +2523,7 @@ config load_config( const fc::path& datadir )
return _chain_db->get_transactions_for_block(id);
}

map<fc::time_point, fc::exception> client_impl::list_errors( const fc::time_point& start_time, int32_t first_error_number, uint32_t limit )const
map<fc::time_point, fc::exception> client_impl::list_errors( const fc::time_point& start_time, int32_t first_error_number, uint32_t limit, const string& filename )const
{
map<fc::time_point, fc::exception> result;
auto itr = _exception_db.lower_bound( start_time );
Expand All @@ -2536,8 +2536,17 @@ config load_config( const fc::path& datadir )
if (--limit == 0)
break;
}

if( filename != "" )
{
auto file_path = fc::path( filename );
FC_ASSERT( !fc::exists( file_path ) );
fc::json::save_to_file( result, file_path, true );
}

return result;
}

map<fc::time_point, std::string> client_impl::list_errors_brief( const fc::time_point& start_time, int32_t first_error_number, uint32_t limit )const
{
map<fc::time_point, std::string> result;
Expand Down

0 comments on commit b01e329

Please sign in to comment.