Clean up logging

This commit is contained in:
Alexey Pelykh 2012-03-14 15:03:54 +02:00
parent dd51beff1f
commit 2dc5acfcd7
2 changed files with 9 additions and 16 deletions

View file

@ -17,7 +17,6 @@
#include "multipolygons.h" #include "multipolygons.h"
#include "proto/osmand_odb.pb.h" #include "proto/osmand_odb.pb.h"
char errorMsg[1024];
#define INT_MAX 0x7fffffff /* max value for an int */ #define INT_MAX 0x7fffffff /* max value for an int */
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false #define DO_(EXPRESSION) if (!(EXPRESSION)) return false
using namespace google::protobuf; using namespace google::protobuf;
@ -347,8 +346,7 @@ bool initMapStructure(io::CodedInputStream* input, BinaryMapFile* file) {
} }
} }
if (version != versionConfirm) { if (version != versionConfirm) {
__android_log_print(ANDROID_LOG_WARN, "net.osmand", __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Corrupted file. It should be ended as it starts with version");
"Corrupted file. It should be ended as it starts with version");
return false; return false;
} }
return true; return true;
@ -746,9 +744,8 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
proccessMultiPolygons(multyPolygons, q.left, q.right, q.bottom, q.top, q.zoom, result->result); proccessMultiPolygons(multyPolygons, q.left, q.right, q.bottom, q.top, q.zoom, result->result);
if(q.result.size() > 0) { if(q.result.size() > 0) {
sprintf(errorMsg, "Search : tree - read( %d), accept( %d), objs - visit( %d), accept(%d), in result(%d) ", q.numberOfReadSubtrees, __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Search : tree - read( %d), accept( %d), objs - visit( %d), accept(%d), in result(%d) ", q.numberOfReadSubtrees,
q.numberOfAcceptedSubtrees, q.numberOfVisitedObjects, q.numberOfAcceptedObjects, result->result.size()); q.numberOfAcceptedSubtrees, q.numberOfVisitedObjects, q.numberOfAcceptedObjects, result->result.size());
__android_log_print(ANDROID_LOG_INFO, "net.osmand", errorMsg);
} }
delete req; delete req;
return (jint)result; return (jint)result;
@ -771,8 +768,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLi
FILE* file = fopen(inputName.c_str(), "r"); FILE* file = fopen(inputName.c_str(), "r");
if (file == NULL) { if (file == NULL) {
sprintf(errorMsg, "File could not be open to read from C : %s", inputName.c_str()); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "File could not be open to read from C : %s", inputName.c_str());
__android_log_print(ANDROID_LOG_WARN, "net.osmand", errorMsg);
return false; return false;
} }
BinaryMapFile* mapFile = new BinaryMapFile(); BinaryMapFile* mapFile = new BinaryMapFile();
@ -782,8 +778,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLi
io::CodedInputStream cis(&input); io::CodedInputStream cis(&input);
cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2);
if (!initMapStructure(&cis, mapFile)) { if (!initMapStructure(&cis, mapFile)) {
sprintf(errorMsg, "File not initialised : %s", inputName.c_str()); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "File not initialised : %s", inputName.c_str());
__android_log_print(ANDROID_LOG_WARN, "net.osmand", errorMsg);
delete mapFile; delete mapFile;
return false; return false;
} }

View file

@ -13,7 +13,6 @@
#define INT_MAX 0x7fffffff /* max value for an int */ #define INT_MAX 0x7fffffff /* max value for an int */
#define INT_MIN (-0x7fffffff-1) /* min value for an int */ #define INT_MIN (-0x7fffffff-1) /* min value for an int */
char textMsg[1024] ;
struct tagValueType { struct tagValueType {
int type; int type;
std::string tag; std::string tag;
@ -118,7 +117,7 @@ MultiPolygonObject* processMultiPolygon(int leftX, int rightX, int bottomY, int
whole.push_back(int_pair(leftX, bottomY)); whole.push_back(int_pair(leftX, bottomY));
whole.push_back(int_pair(rightX, bottomY)); whole.push_back(int_pair(rightX, bottomY));
completedRings.push_back(whole); completedRings.push_back(whole);
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "!!! Isolated island !!!"); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "!!! Isolated island !!!");
} }
} }
@ -161,14 +160,13 @@ void proccessMultiPolygons(std::map<tagValueType, std::vector<MapDataObject*> >&
completedRingNames.clear(); completedRingNames.clear();
incompletedRingNames.clear(); incompletedRingNames.clear();
sprintf(textMsg, "Process multipolygon %s %s direct list %d rev %d", val->first.tag.c_str(), val->first.value.c_str(), directList->size(), inverselist->size()); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Process multipolygon %s %s direct list %d rev %d", val->first.tag.c_str(), val->first.value.c_str(), directList->size(), inverselist->size());
__android_log_print(ANDROID_LOG_INFO, "net.osmand", textMsg);
MultiPolygonObject* pl = processMultiPolygon(leftX, rightX, bottomY, topY, completedRings, incompletedRings, MultiPolygonObject* pl = processMultiPolygon(leftX, rightX, bottomY, topY, completedRings, incompletedRings,
completedRingNames, incompletedRingNames, val->first, *directList, *inverselist, zoom); completedRingNames, incompletedRingNames, val->first, *directList, *inverselist, zoom);
if (pl != NULL) { if (pl != NULL) {
listPolygons.push_back(pl); listPolygons.push_back(pl);
} else { } else {
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "Multipolygon skipped"); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Multipolygon skipped");
} }
} }
} }
@ -361,7 +359,7 @@ void unifyIncompletedRings(std::vector<std::vector<int_pair> >& incompletedRings
// System.err // System.err
// .println(MessageFormat.format(dbId + str, dx, dy, dsx, dsy, leftX + "", topY + "", rightX + "", bottomY + "")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ // .println(MessageFormat.format(dbId + str, dx, dy, dsx, dsy, leftX + "", topY + "", rightX + "", bottomY + "")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
// } // }
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "Error processing multipolygon"); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Error processing multipolygon");
} else { } else {
nonvisitedRings.insert(j); nonvisitedRings.insert(j);
} }