Skip to content

Commit a8f6d5c

Browse files
committed
improve error logging with file paths and context
1 parent c29ef2d commit a8f6d5c

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

concore.hpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,14 @@ class Concore{
353353
ostringstream ss;
354354
ss << infile.rdbuf(); // reading data
355355
ins = ss.str();
356-
retrycount++;
357356
infile.close();
358357
}
359358
else{
360-
retrycount++;
361359
throw 505;
362360
}
363361
}
364-
//observed retry count in C++ from various tests is approx 80.
365362
catch(...){
366-
cout<<"Read error";
363+
cerr << "Error reading " << inpath << port << "/" << name << " (retry " << retry << ")" << endl;
367364
}
368365
retry++;
369366
}
@@ -416,16 +413,13 @@ class Concore{
416413
if(shmId_get != -1) {
417414
std::string message(sharedData_get, strnlen(sharedData_get, 256));
418415
ins = message;
419-
retrycount++;
420416
}
421417
else{
422-
retrycount++;
423418
throw 505;
424419
}
425420
}
426-
//observed retry count in C++ from various tests is approx 80.
427421
catch(...){
428-
std::cout << "Read error" << std::endl;
422+
cerr << "Error reading from shared memory port " << port << " name " << name << " (retry " << retry << ")" << endl;
429423
}
430424
retry++;
431425
}
@@ -501,7 +495,7 @@ class Concore{
501495
}
502496

503497
catch(...){
504-
cout<<"skipping +"<<outpath<<port<<" /"<<name;
498+
cerr << "Error writing to " << outpath << port << "/" << name << endl;
505499
}
506500
}
507501

@@ -526,7 +520,7 @@ class Concore{
526520
else throw 505;
527521
}
528522
catch(...){
529-
cout<<"skipping +"<<outpath<<port<<" /"<<name;
523+
cerr << "Error writing to " << outpath << port << "/" << name << endl;
530524
}
531525
}
532526

@@ -556,7 +550,7 @@ class Concore{
556550
}
557551

558552
catch(...){
559-
cout<<"skipping +"<<outpath<<port<<" /"<<name;
553+
cerr << "Error writing to shared memory port " << port << " name " << name << endl;
560554
}
561555
}
562556

@@ -577,7 +571,7 @@ class Concore{
577571
else throw 505;
578572
}
579573
catch(...){
580-
cout<<"skipping +"<<outpath<<port<<" /"<<name;
574+
cerr << "Error writing to shared memory port " << port << " name " << name << endl;
581575
}
582576
}
583577

0 commit comments

Comments
 (0)