mirror of
https://github.com/nasa/trick.git
synced 2025-01-29 15:43:57 +00:00
Merge pull request #366 from iamthad/use_stderr
Use std::cerr instead of std::cout for error messages
This commit is contained in:
commit
a831cbfaa8
@ -24,7 +24,7 @@ static ut_system * get_u_system() {
|
||||
/* Initialize the udunits-2 library */
|
||||
ut_set_error_message_handler(ut_ignore) ;
|
||||
if( (u_system = ut_read_xml( NULL )) == NULL ) {
|
||||
std::cout << "Error initializing udunits-2 unit system" << std::endl ;
|
||||
std::cerr << "Error initializing udunits-2 unit system" << std::endl ;
|
||||
exit(-1);
|
||||
}
|
||||
ut_set_error_message_handler(ut_write_to_stderr) ;
|
||||
@ -98,7 +98,7 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e
|
||||
} else {
|
||||
//char error_msg[1024] ;
|
||||
//regerror( ret , ®_expr , (char *)error_msg , 1024 ) ;
|
||||
//std::cout << error_msg << std::endl ;
|
||||
//std::cerr << error_msg << std::endl ;
|
||||
}
|
||||
return std::string() ;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ static void _mkdir(const char *dir) {
|
||||
if ( stat( tmp , &buf ) != 0 ) {
|
||||
int returnValue = mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
if (returnValue) {
|
||||
std::cout << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl;
|
||||
std::cerr << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ static void _mkdir(const char *dir) {
|
||||
if ( stat( tmp , &buf ) != 0 ) {
|
||||
int returnValue = mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
if (returnValue) {
|
||||
std::cout << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl;
|
||||
std::cerr << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ Csv::Csv(char * file_name , char * param_name ) {
|
||||
len = strlen(param_name) ;
|
||||
|
||||
if ((fp_ = fopen(file_name , "r")) == 0 ) {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
exit(-1) ;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ int CsvLocateParam( char * file_name , char * param_name ) {
|
||||
|
||||
}
|
||||
else {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
|
@ -74,7 +74,7 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
||||
fileName_ = file_name;
|
||||
|
||||
if ((fp_ = fopen(file_name, "r")) == 0) {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
||||
int field_index, field_num;
|
||||
|
||||
if ((fp = fopen(file_name, "r")) == 0) {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ MatLab4::MatLab4(char * file_name , char * param_name , char * time_name ) {
|
||||
TRICK_GET_BYTE_ORDER(my_byte_order) ;
|
||||
|
||||
if ((fp_ = fopen(file_name , "r")) == 0 ) {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
exit(-1) ;
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ int MatLab4LocateParam( char *file_name , char *param_name , char *time_name ) {
|
||||
TRICK_GET_BYTE_ORDER(my_byte_order) ;
|
||||
|
||||
if ((fp = fopen(file_name , "r")) == 0 ) {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
exit(-1) ;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ TrickBinary::TrickBinary(char * file_name , char * param_name ) {
|
||||
record_ = new char[record_size_] ;
|
||||
}
|
||||
else {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ int TrickBinaryGetNumVariables(const char* file_name) {
|
||||
fread(&num_params , 4 , 1 , fp ) ;
|
||||
if ( swap ) { num_params = trick_byteswap_int(num_params) ; }
|
||||
} else {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ char** TrickBinaryGetVariableNames(const char* file_name) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ char** TrickBinaryGetVariableUnits(const char* file_name) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
std::cerr << "ERROR: Couldn't open \"" << file_name << "\": " << std::strerror(errno) << std::endl;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ TrickHDF5::TrickHDF5(char *file_name , char *parameter_name , char *time_name) {
|
||||
* Open the HDF5 file.
|
||||
*/
|
||||
if ( (file = H5Fopen( file_name, H5F_ACC_RDONLY, H5P_DEFAULT )) < 0 ) {
|
||||
cout << "ERROR: Couldn't open file \"" << file_name << "\"" << endl;
|
||||
cerr << "ERROR: Couldn't open file \"" << file_name << "\"" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ TrickHDF5::TrickHDF5(char *file_name , char *parameter_name , char *time_name) {
|
||||
*/
|
||||
root_group = H5Gopen( file, "/", H5P_DEFAULT );
|
||||
if ( root_group < 0 ) {
|
||||
cout << "ERROR: Couldn't open group \"" << "/" << "\"" << endl;
|
||||
cerr << "ERROR: Couldn't open group \"" << "/" << "\"" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -77,13 +77,13 @@ TrickHDF5::TrickHDF5(char *file_name , char *parameter_name , char *time_name) {
|
||||
*/
|
||||
parameter_dataset = H5PTopen( root_group, parameter_name );
|
||||
if ( H5PTis_valid(parameter_dataset) < 0 ) {
|
||||
cout << "ERROR: Couldn't open packet table \""
|
||||
cerr << "ERROR: Couldn't open packet table \""
|
||||
<< parameter_name << "\"" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
time_dataset = H5PTopen( root_group, time_name );
|
||||
if ( H5PTis_valid(time_dataset) < 0 ) {
|
||||
cout << "ERROR: Couldn't open packet table \""
|
||||
cerr << "ERROR: Couldn't open packet table \""
|
||||
<< time_name << "\"" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
@ -185,14 +185,14 @@ int HDF5LocateParam( const char * file_name, const char * parameter_name ) {
|
||||
//! Open an existing HDF5 file and get a file identifier.
|
||||
hid_t file = H5Fopen(file_name, H5F_ACC_RDONLY, H5P_DEFAULT);
|
||||
if (file < 0) {
|
||||
cout << "ERROR: Couldn't open file \"" << file_name << "\"" << endl;
|
||||
cerr << "ERROR: Couldn't open file \"" << file_name << "\"" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Open group containing data.
|
||||
hid_t group = H5Gopen(file, "/", H5P_DEFAULT);
|
||||
if (group < 0) {
|
||||
cout << "ERROR: Couldn't open group \"" << "/" << "\"" << endl;
|
||||
cerr << "ERROR: Couldn't open group \"" << "/" << "\"" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ int HDF5LocateParam( const char * file_name, const char * parameter_name ) {
|
||||
*/
|
||||
hid_t packet_table = H5PTopen(group, parameter_name);
|
||||
if ( H5PTis_valid(packet_table) < 0 ) {
|
||||
cout << "ERROR: Couldn't open packet table \""
|
||||
cerr << "ERROR: Couldn't open packet table \""
|
||||
<< parameter_name << "\"" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ int LogData::setUnit(int paramIdx, std::string to_units)
|
||||
unitVal_[paramIdx] = cv_convert_double(converter, 1.0 ) - biasVal_[paramIdx] ;
|
||||
cv_free(converter) ;
|
||||
} else {
|
||||
std::cout << "Units conversion error from " << from_units << " to " << to_units << std::endl ;
|
||||
std::cerr << "Units conversion error from " << from_units << " to " << to_units << std::endl ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ void* ArrayDataType::createInstance(unsigned int num) const {
|
||||
if (subType != NULL) {
|
||||
return subType->createInstance( num * elementCount );
|
||||
} else {
|
||||
std::cout << "ERROR: Can't create an instance of an unvalidated type." << std::endl;
|
||||
std::cerr << "ERROR: Can't create an instance of an unvalidated type." << std::endl;
|
||||
return (void*) NULL;
|
||||
}
|
||||
}
|
||||
|
@ -136,13 +136,13 @@ void* CompositeDataType::createInstance(unsigned int num) const {
|
||||
if (allocator == NULL) {
|
||||
// Allocate using calloc.
|
||||
if ((address = calloc( (size_t)num, (size_t)structSize )) == NULL) {
|
||||
std::cout << "ERROR: Out of memory." << std::endl;
|
||||
std::cerr << "ERROR: Out of memory." << std::endl;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
} else {
|
||||
// Allocate using the allocator.
|
||||
if ((address = allocator( num)) == NULL) {
|
||||
std::cout << "ERROR: Out of memory." << std::endl;
|
||||
std::cerr << "ERROR: Out of memory." << std::endl;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void* MemMgr::declare_var( const std::string& typeSpecifier,
|
||||
void* suppliedAllocation ) {
|
||||
|
||||
if ( var_exists( variableName )) {
|
||||
std::cout << "ERROR: Variable " << variableName << " already declared." << std::endl;
|
||||
std::cerr << "ERROR: Variable " << variableName << " already declared." << std::endl;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ void Trick::MemoryManager::get_alloc_deps_in_allocation(ALLOC_INFO* alloc_info )
|
||||
}
|
||||
|
||||
if (alloc_info == NULL) {
|
||||
std::cout << "ERROR: Trick::MemoryManager::get_alloc_deps_in_allocation called with alloc_info == NULL." << std::endl;
|
||||
std::cerr << "ERROR: Trick::MemoryManager::get_alloc_deps_in_allocation called with alloc_info == NULL." << std::endl;
|
||||
std::cout.flush();
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ void Trick::MemoryManager::get_stl_dependencies( ALLOC_INFO* alloc_info ) {
|
||||
}
|
||||
|
||||
if (alloc_info == NULL) {
|
||||
std::cout << "ERROR: Trick::MemoryManager::get_stl_dependencies called with alloc_info == NULL." << std::endl;
|
||||
std::cerr << "ERROR: Trick::MemoryManager::get_stl_dependencies called with alloc_info == NULL." << std::endl;
|
||||
std::cout.flush();
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ void Trick::MemoryManager::restore_stls( ALLOC_INFO* alloc_info ) {
|
||||
}
|
||||
|
||||
if (alloc_info == NULL) {
|
||||
std::cout << "ERROR: Trick::MemoryManager::restore_stls called with alloc_info == NULL." << std::endl;
|
||||
std::cerr << "ERROR: Trick::MemoryManager::restore_stls called with alloc_info == NULL." << std::endl;
|
||||
std::cout.flush();
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user