assert that there is an open logger file when trying to log geojson output (#3417)

This commit is contained in:
Huyen Chau Nguyen 2016-12-09 14:58:20 +01:00 committed by GitHub
parent 03d653c0bb
commit 62f0e11bfa

View File

@ -63,11 +63,11 @@ class GeojsonLogger
// make sure to syncronize logging output, our writing should be sequential // make sure to syncronize logging output, our writing should be sequential
std::lock_guard<std::mutex> guard(lock); std::lock_guard<std::mutex> guard(lock);
// if there is no logfile, we cannot write // if there is no logfile, we cannot write (possible reason: the guard might be out of scope
// (e.g. if it is anonymous))
if (!ofs.is_open() || (nullptr == policy)) if (!ofs.is_open() || (nullptr == policy))
{ {
// this can only happend between two guards when concurrent writing occurs throw util::exception("Trying to use the geojson printer without an open logger.");
return false;
} }
// use our policy to convert the arguments into geojson, this can be done in parallel // use our policy to convert the arguments into geojson, this can be done in parallel