From ef221e1c6ce9471401cfcdac00f7dc8aaa979f23 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 8 Aug 2013 14:17:01 +0200 Subject: [PATCH] Replacing log macros by more sophisticated mechanism --- Algorithms/StronglyConnectedComponents.h | 34 +-- Contractor/ContractionCleanup.h | 261 ------------------ Contractor/Contractor.h | 12 +- Contractor/EdgeBasedGraphFactory.cpp | 28 +- Contractor/EdgeBasedGraphFactory.h | 1 + Contractor/TemporaryStorage.cpp | 2 +- Contractor/TemporaryStorage.h | 1 + DataStructures/NodeInformationHelpDesk.h | 8 +- DataStructures/StaticGraph.h | 10 +- DataStructures/StaticRTree.h | 31 ++- Descriptors/DescriptionFactory.cpp | 14 +- Descriptors/DescriptionFactory.h | 1 + Extractor/BaseParser.cpp | 10 +- Extractor/BaseParser.h | 1 + Extractor/ExtractionContainers.cpp | 4 +- Extractor/ExtractionContainers.h | 1 + Extractor/ExtractorCallbacks.cpp | 7 +- Extractor/PBFParser.cpp | 9 +- Extractor/PBFParser.h | 1 + Extractor/ScriptingEnvironment.cpp | 2 +- Extractor/ScriptingEnvironment.h | 1 + Extractor/XMLParser.cpp | 4 +- Extractor/XMLParser.h | 1 + Plugins/ViaRoutePlugin.h | 17 +- RoutingAlgorithms/AlternativePathRouting.h | 2 +- RoutingAlgorithms/BasicRoutingInterface.h | 3 +- Server/DataStructures/QueryObjectsStorage.cpp | 17 +- Server/DataStructures/QueryObjectsStorage.h | 3 +- Server/RequestHandler.h | 8 +- Tools/componentAnalysis.cpp | 12 +- Util/GraphLoader.h | 45 +-- Util/InputFileUtil.h | 4 +- createHierarchy.cpp | 87 ++++-- extractor.cpp | 30 +- routed.cpp | 5 +- typedefs.h | 11 +- 36 files changed, 242 insertions(+), 446 deletions(-) delete mode 100644 Contractor/ContractionCleanup.h diff --git a/Algorithms/StronglyConnectedComponents.h b/Algorithms/StronglyConnectedComponents.h index 264e41b33..2377258f8 100644 --- a/Algorithms/StronglyConnectedComponents.h +++ b/Algorithms/StronglyConnectedComponents.h @@ -33,6 +33,8 @@ Strongly connected components using Tarjan's Algorithm #include "../DataStructures/Restriction.h" #include "../DataStructures/TurnInstructions.h" +#include "../Util/SimpleLogger.h" + #include #include #include @@ -243,7 +245,7 @@ public: bool beforeRecursion = recursionStack.top().first; TarjanStackFrame currentFrame = recursionStack.top().second; NodeID v = currentFrame.v; -// INFO("popping node " << v << (beforeRecursion ? " before " : " after ") << "recursion"); +// SimpleLogger().Write() << "popping node " << v << (beforeRecursion ? " before " : " after ") << "recursion"; recursionStack.pop(); if(beforeRecursion) { @@ -256,45 +258,45 @@ public: tarjanStack.push(v); tarjanNodes[v].onStack = true; ++index; -// INFO("pushing " << v << " onto tarjan stack, idx[" << v << "]=" << tarjanNodes[v].index << ", lowlink["<< v << "]=" << tarjanNodes[v].lowlink); +// SimpleLogger().Write() << "pushing " << v << " onto tarjan stack, idx[" << v << "]=" << tarjanNodes[v].index << ", lowlink["<< v << "]=" << tarjanNodes[v].lowlink; //Traverse outgoing edges for(TarjanDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) { TarjanDynamicGraph::NodeIterator vprime = _nodeBasedGraph->GetTarget(e2); -// INFO("traversing edge (" << v << "," << vprime << ")"); +// SimpleLogger().Write() << "traversing edge (" << v << "," << vprime << ")"; if(UINT_MAX == tarjanNodes[vprime].index) { recursionStack.push(std::make_pair(true,TarjanStackFrame(vprime, v))); } else { -// INFO("Node " << vprime << " is already explored"); +// SimpleLogger().Write() << "Node " << vprime << " is already explored"; if(tarjanNodes[vprime].onStack) { unsigned newLowlink = std::min(tarjanNodes[v].lowlink, tarjanNodes[vprime].index); -// INFO("Setting lowlink[" << v << "] from " << tarjanNodes[v].lowlink << " to " << newLowlink); +// SimpleLogger().Write() << "Setting lowlink[" << v << "] from " << tarjanNodes[v].lowlink << " to " << newLowlink; tarjanNodes[v].lowlink = newLowlink; // } else { -// INFO("But node " << vprime << " is not on stack"); +// SimpleLogger().Write() << "But node " << vprime << " is not on stack"; } } } } else { -// INFO("we are at the end of recursion and checking node " << v); +// SimpleLogger().Write() << "we are at the end of recursion and checking node " << v; { // setting lowlink in its own scope so it does not pollute namespace // NodeID parent = (UINT_MAX == tarjanNodes[v].parent ? v : tarjanNodes[v].parent ); -// INFO("parent=" << currentFrame.parent); -// INFO("tarjanNodes[" << v << "].lowlink=" << tarjanNodes[v].lowlink << ", tarjanNodes[" << currentFrame.parent << "].lowlink=" << tarjanNodes[currentFrame.parent].lowlink); +// SimpleLogger().Write() << "parent=" << currentFrame.parent; +// SimpleLogger().Write() << "tarjanNodes[" << v << "].lowlink=" << tarjanNodes[v].lowlink << ", tarjanNodes[" << currentFrame.parent << "].lowlink=" << tarjanNodes[currentFrame.parent].lowlink; //Note the index shift by 1 compared to the recursive version tarjanNodes[currentFrame.parent].lowlink = std::min(tarjanNodes[currentFrame.parent].lowlink, tarjanNodes[v].lowlink); -// INFO("Setting tarjanNodes[" << currentFrame.parent <<"].lowlink=" << tarjanNodes[currentFrame.parent].lowlink); +// SimpleLogger().Write() << "Setting tarjanNodes[" << currentFrame.parent <<"].lowlink=" << tarjanNodes[currentFrame.parent].lowlink; } -// INFO("tarjanNodes[" << v << "].lowlink=" << tarjanNodes[v].lowlink << ", tarjanNodes[" << v << "].index=" << tarjanNodes[v].index); +// SimpleLogger().Write() << "tarjanNodes[" << v << "].lowlink=" << tarjanNodes[v].lowlink << ", tarjanNodes[" << v << "].index=" << tarjanNodes[v].index; //after recursion, lets do cycle checking //Check if we found a cycle. This is the bottom part of the recursion if(tarjanNodes[v].lowlink == tarjanNodes[v].index) { NodeID vprime; do { -// INFO("identified component " << currentComponent << ": " << tarjanStack.top()); +// SimpleLogger().Write() << "identified component " << currentComponent << ": " << tarjanStack.top(); vprime = tarjanStack.top(); tarjanStack.pop(); tarjanNodes[vprime].onStack = false; componentsIndex[vprime] = currentComponent; @@ -302,7 +304,7 @@ public: } while( v != vprime); vectorOfComponentSizes.push_back(sizeOfCurrentComponent); if(sizeOfCurrentComponent > 1000) - INFO("large component [" << currentComponent << "]=" << sizeOfCurrentComponent); + SimpleLogger().Write() << "large component [" << currentComponent << "]=" << sizeOfCurrentComponent; ++currentComponent; sizeOfCurrentComponent = 0; } @@ -310,14 +312,14 @@ public: } } - INFO("identified: " << vectorOfComponentSizes.size() << " many components, marking small components"); + SimpleLogger().Write() << "identified: " << vectorOfComponentSizes.size() << " many components, marking small components"; int singleCounter = 0; for(unsigned i = 0; i < vectorOfComponentSizes.size(); ++i){ if(1 == vectorOfComponentSizes[i]) ++singleCounter; } - INFO("identified " << singleCounter << " SCCs of size 1"); + SimpleLogger().Write() << "identified " << singleCounter << " SCCs of size 1"; uint64_t total_network_distance = 0; p.reinit(_nodeBasedGraph->GetNumberOfNodes()); for(TarjanDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) { @@ -363,7 +365,7 @@ public: OGRDataSource::DestroyDataSource( poDS ); std::vector().swap(vectorOfComponentSizes); std::vector().swap(componentsIndex); - INFO("total network distance: " << total_network_distance/100/1000. << " km"); + SimpleLogger().Write() << "total network distance: " << (uint64_t)total_network_distance/100/1000. << " km"; } private: unsigned CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const { diff --git a/Contractor/ContractionCleanup.h b/Contractor/ContractionCleanup.h deleted file mode 100644 index e42dad3a7..000000000 --- a/Contractor/ContractionCleanup.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - open source routing machine - Copyright (C) Dennis Luxen, others 2010 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. - */ - -#ifndef CONTRACTIONCLEANUP_H_INCLUDED -#define CONTRACTIONCLEANUP_H_INCLUDED - -#include -#ifndef _WIN32 -#include -#endif -#include "Contractor.h" - -class ContractionCleanup { -private: - - struct _CleanupHeapData { - NodeID parent; - _CleanupHeapData( NodeID p ) { - parent = p; - } - }; - typedef BinaryHeap< NodeID, NodeID, int, _CleanupHeapData > _Heap; - - struct _ThreadData { - _Heap* _heapForward; - _Heap* _heapBackward; - _ThreadData( NodeID nodes ) { - _heapBackward = new _Heap(nodes); - _heapForward = new _Heap(nodes); - } - ~_ThreadData() { - delete _heapBackward; - delete _heapForward; - } - }; - -public: - - struct Edge { - NodeID source; - NodeID target; - struct EdgeData { - NodeID via; - unsigned nameID; - int distance; - TurnInstruction turnInstruction; - bool shortcut:1; - bool forward:1; - bool backward:1; - } data; - bool operator<( const Edge& right ) const { - if ( source != right.source ) - return source < right.source; - return target < right.target; - } - - //sorts by source and other attributes - static bool CompareBySource( const Edge& left, const Edge& right ) { - if ( left.source != right.source ) - return left.source < right.source; - int l = ( left.data.forward ? -1 : 0 ) + ( left.data.backward ? -1 : 0 ); - int r = ( right.data.forward ? -1 : 0 ) + ( right.data.backward ? -1 : 0 ); - if ( l != r ) - return l < r; - if ( left.target != right.target ) - return left.target < right.target; - return left.data.distance < right.data.distance; - } - - bool operator== ( const Edge& right ) const { - return ( source == right.source && target == right.target && data.distance == right.data.distance && - data.shortcut == right.data.shortcut && data.forward == right.data.forward && data.backward == right.data.backward - && data.via == right.data.via && data.nameID == right.data.nameID - ); - } - }; - - ContractionCleanup( int numNodes, const std::vector< Edge >& edges ) { - _graph = edges; - _numNodes = numNodes; - } - - ~ContractionCleanup() { - - } - - void Run() { - RemoveUselessShortcuts(); - } - - template< class EdgeT > - void GetData( std::vector< EdgeT >& edges ) { - for ( int edge = 0, endEdges = ( int ) _graph.size(); edge != endEdges; ++edge ) { - if(_graph[edge].data.forward || _graph[edge].data.backward) { - EdgeT newEdge; - newEdge.source = _graph[edge].source; - newEdge.target = _graph[edge].target; - newEdge.data = _graph[edge].data; - edges.push_back( newEdge ); - } - } - sort( edges.begin(), edges.end() ); - } - -private: - - double _Timestamp() { - struct timeval tp; - gettimeofday(&tp, NULL); - return double(tp.tv_sec) + tp.tv_usec / 1000000.; - } - - void BuildOutgoingGraph() { - //sort edges by source - sort( _graph.begin(), _graph.end(), Edge::CompareBySource ); - try { - _firstEdge.resize( _numNodes + 1 ); - } catch(...) { - ERR("Not enough RAM on machine"); - return; - } - _firstEdge[0] = 0; - for ( NodeID i = 0, node = 0; i < ( NodeID ) _graph.size(); i++ ) { - while ( _graph[i].source != node ) - _firstEdge[++node] = i; - if ( i == ( NodeID ) _graph.size() - 1 ) - while ( node < _numNodes ) - _firstEdge[++node] = ( int ) _graph.size(); - } - } - - void RemoveUselessShortcuts() { - int maxThreads = omp_get_max_threads(); - std::vector < _ThreadData* > threadData; - for ( int threadNum = 0; threadNum < maxThreads; ++threadNum ) { - threadData.push_back( new _ThreadData( _numNodes ) ); - } - - INFO("Scanning for useless shortcuts"); - BuildOutgoingGraph(); -/* - #pragma omp parallel for - for ( int i = 0; i < ( int ) _graph.size(); i++ ) { - //only remove shortcuts - if ( !_graph[i].data.shortcut ) - continue; - - if ( _graph[i].data.forward ) { - int result = _ComputeDistance( _graph[i].source, _graph[i].target, threadData[omp_get_thread_num()] ); - if ( result < _graph[i].data.distance ) { - _graph[i].data.forward = false; - } - } - if ( _graph[i].data.backward ) { - int result = _ComputeDistance( _graph[i].target, _graph[i].source, threadData[omp_get_thread_num()] ); - if ( result < _graph[i].data.distance ) { - _graph[i].data.backward = false; - } - } - } -*/ - INFO("Removing edges"); - int useful = 0; - for ( int i = 0; i < ( int ) _graph.size(); i++ ) { - if ( !_graph[i].data.forward && !_graph[i].data.backward && _graph[i].data.shortcut ) { - continue; - } - _graph[useful] = _graph[i]; - useful++; - } - INFO("Removed " << _graph.size() - useful << " useless shortcuts"); - _graph.resize( useful ); - - for ( int threadNum = 0; threadNum < maxThreads; ++threadNum ) { - delete threadData[threadNum]; - } - } - - void _ComputeStep( _Heap* heapForward, _Heap* heapBackward, bool forwardDirection, NodeID* middle, int* targetDistance ) { - - const NodeID node = heapForward->DeleteMin(); - const int distance = heapForward->GetKey( node ); - - if ( distance > *targetDistance ) { - heapForward->DeleteAll(); - return; - } - - if ( heapBackward->WasInserted( node ) ) { - const int newDistance = heapBackward->GetKey( node ) + distance; - if ( newDistance < *targetDistance ) { - *middle = node; - *targetDistance = newDistance; - } - } - - for ( int edge = _firstEdge[node], endEdges = _firstEdge[node + 1]; edge != endEdges; ++edge ) { - const NodeID to = _graph[edge].target; - const int edgeWeight = _graph[edge].data.distance; - assert( edgeWeight > 0 ); - const int toDistance = distance + edgeWeight; - - if ( (forwardDirection ? _graph[edge].data.forward : _graph[edge].data.backward ) ) { - //New Node discovered -> Add to Heap + Node Info Storage - if ( !heapForward->WasInserted( to ) ) - heapForward->Insert( to, toDistance, node ); - - //Found a shorter Path -> Update distance - else if ( toDistance < heapForward->GetKey( to ) ) { - heapForward->DecreaseKey( to, toDistance ); - //new parent - heapForward->GetData( to ) = node; - } - } - } - } - - int _ComputeDistance( NodeID source, NodeID target, _ThreadData * data ) { - data->_heapForward->Clear(); - data->_heapBackward->Clear(); - //insert source into heap - data->_heapForward->Insert( source, 0, source ); - data->_heapBackward->Insert( target, 0, target ); - - int targetDistance = std::numeric_limits< int >::max(); - NodeID middle = std::numeric_limits::max(); - - while ( data->_heapForward->Size() + data->_heapBackward->Size() > 0 ) { - if ( data->_heapForward->Size() > 0 ) { - _ComputeStep( data->_heapForward, data->_heapBackward, true, &middle, &targetDistance ); - } - - if ( data->_heapBackward->Size() > 0 ) { - _ComputeStep( data->_heapBackward, data->_heapForward, false, &middle, &targetDistance ); - } - } - return targetDistance; - } - NodeID _numNodes; - std::vector< Edge > _graph; - std::vector< unsigned > _firstEdge; -}; - -#endif // CONTRACTIONCLEANUP_H_INCLUDED diff --git a/Contractor/Contractor.h b/Contractor/Contractor.h index bbc3ad58e..1ffc0435b 100644 --- a/Contractor/Contractor.h +++ b/Contractor/Contractor.h @@ -29,6 +29,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../DataStructures/XORFastHash.h" #include "../DataStructures/XORFastHashStorage.h" #include "../Util/OpenMPWrapper.h" +#include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" #include @@ -124,7 +125,8 @@ public: BOOST_ASSERT_MSG( newEdge.data.distance > 0, "edge distance < 1" ); #ifndef NDEBUG if ( newEdge.data.distance > 24 * 60 * 60 * 10 ) { - WARN("Edge weight large -> " << newEdge.data.distance); + SimpleLogger().Write(logWARNING) << + "Edge weight large -> " << newEdge.data.distance; } #endif edges.push_back( newEdge ); @@ -198,9 +200,9 @@ public: // } // } // - // INFO("edges at node with id " << highestNode << " has degree " << maxdegree); + // SimpleLogger().Write() << "edges at node with id " << highestNode << " has degree " << maxdegree; // for(unsigned i = _graph->BeginEdges(highestNode); i < _graph->EndEdges(highestNode); ++i) { - // INFO(" ->(" << highestNode << "," << _graph->GetTarget(i) << "); via: " << _graph->GetEdgeData(i).via); + // SimpleLogger().Write() << " ->(" << highestNode << "," << _graph->GetTarget(i) << "); via: " << _graph->GetEdgeData(i).via; // } //Create temporary file @@ -430,7 +432,7 @@ public: // avgdegree /= std::max((unsigned)1,(unsigned)remainingNodes.size() ); // quaddegree /= std::max((unsigned)1,(unsigned)remainingNodes.size() ); // - // INFO("rest: " << remainingNodes.size() << ", max: " << maxdegree << ", min: " << mindegree << ", avg: " << avgdegree << ", quad: " << quaddegree); + // SimpleLogger().Write() << "rest: " << remainingNodes.size() << ", max: " << maxdegree << ", min: " << mindegree << ", avg: " << avgdegree << ", quad: " << quaddegree; p.printStatus(numberOfContractedNodes); } @@ -443,7 +445,7 @@ public: template< class Edge > inline void GetEdges( DeallocatingVector< Edge >& edges ) { Percent p (_graph->GetNumberOfNodes()); - INFO("Getting edges of minimized graph"); + SimpleLogger().Write() << "Getting edges of minimized graph"; NodeID numberOfNodes = _graph->GetNumberOfNodes(); if(_graph->GetNumberOfNodes()) { for ( NodeID node = 0; node < numberOfNodes; ++node ) { diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 9443c24e4..7da2e4f67 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -162,7 +162,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State originalEdgeDataOutFile.write((char*)&numberOfOriginalEdges, sizeof(unsigned)); - INFO("Identifying small components"); + SimpleLogger().Write() << "Identifying small components"; //Run a BFS on the undirected graph and identify small components std::queue > bfsQueue; std::vector componentsIndex(_nodeBasedGraph->GetNumberOfNodes(), UINT_MAX); @@ -179,7 +179,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State //fetch element from BFS queue std::pair currentQueueItem = bfsQueue.front(); bfsQueue.pop(); - // INFO("sizeof queue: " << bfsQueue.size() << ", sizeOfCurrentComponents: " << sizeOfCurrentComponent << ", settled nodes: " << settledNodes++ << ", max: " << endNodes); + // SimpleLogger().Write() << "sizeof queue: " << bfsQueue.size() << ", sizeOfCurrentComponents: " << sizeOfCurrentComponent << ", settled nodes: " << settledNodes++ << ", max: " << endNodes; const NodeID v = currentQueueItem.first; //current node const NodeID u = currentQueueItem.second; //parent //increment size counter of current component @@ -216,7 +216,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State ++currentComponent; } } - INFO("identified: " << vectorOfComponentSizes.size() << " many components"); + SimpleLogger().Write() << "identified: " << vectorOfComponentSizes.size() << " many components"; p.reinit(_nodeBasedGraph->GetNumberOfNodes()); //loop over all edges and generate new set of nodes. @@ -314,19 +314,19 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State originalEdgeDataOutFile.write((char*)&numberOfOriginalEdges, sizeof(unsigned)); originalEdgeDataOutFile.close(); -// INFO("Sorting edge-based Nodes"); -// std::sort(edgeBasedNodes.begin(), edgeBasedNodes.end()); -// INFO("Removing duplicate nodes (if any)"); +// SimpleLogger().Write() <<"Sorting edge-based Nodes"; +// std::sort(edgeBasedNodes.begin(), edgeBasedNodes.end(); +// SimpleLogger().Write() <<"Removing duplicate nodes (if any)"; // edgeBasedNodes.erase( std::unique(edgeBasedNodes.begin(), edgeBasedNodes.end()), edgeBasedNodes.end() ); -// INFO("Applying vector self-swap trick to free up memory"); -// INFO("size: " << edgeBasedNodes.size() << ", cap: " << edgeBasedNodes.capacity()); +// SimpleLogger().Write() <<"Applying vector self-swap trick to free up memory"; +// SimpleLogger().Write() <<"size: " << edgeBasedNodes.size() << ", cap: " << edgeBasedNodes.capacity(); // std::vector(edgeBasedNodes).swap(edgeBasedNodes); -// INFO("size: " << edgeBasedNodes.size() << ", cap: " << edgeBasedNodes.capacity()); - INFO("Node-based graph contains " << nodeBasedEdgeCounter << " edges"); - INFO("Edge-based graph contains " << edgeBasedEdges.size() << " edges"); -// INFO("Edge-based graph contains " << edgeBasedEdges.size() << " edges, blowup is " << 2*((double)edgeBasedEdges.size()/(double)nodeBasedEdgeCounter)); - INFO("Edge-based graph skipped " << numberOfSkippedTurns << " turns, defined by " << numberOfTurnRestrictions << " restrictions."); - INFO("Generated " << edgeBasedNodes.size() << " edge based nodes"); +// SimpleLogger().Write() <<"size: " << edgeBasedNodes.size() << ", cap: " << edgeBasedNodes.capacity(); + SimpleLogger().Write() <<"Node-based graph contains " << nodeBasedEdgeCounter << " edges"; + SimpleLogger().Write() <<"Edge-based graph contains " << edgeBasedEdges.size() << " edges"; +// SimpleLogger().Write() << "Edge-based graph contains " << edgeBasedEdges.size() << " edges, blowup is " << 2*((double)edgeBasedEdges.size()/(double)nodeBasedEdgeCounter; + SimpleLogger().Write() <<"Edge-based graph skipped " << numberOfSkippedTurns << " turns, defined by " << numberOfTurnRestrictions << " restrictions."; + SimpleLogger().Write() <<"Generated " << edgeBasedNodes.size() << " edge based nodes"; } TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, unsigned& penalty, lua_State *myLuaState) const { diff --git a/Contractor/EdgeBasedGraphFactory.h b/Contractor/EdgeBasedGraphFactory.h index d23f93549..2c5360c1c 100644 --- a/Contractor/EdgeBasedGraphFactory.h +++ b/Contractor/EdgeBasedGraphFactory.h @@ -36,6 +36,7 @@ #include "../DataStructures/Percent.h" #include "../DataStructures/TurnInstructions.h" #include "../Util/LuaUtil.h" +#include "../Util/SimpleLogger.h" #include diff --git a/Contractor/TemporaryStorage.cpp b/Contractor/TemporaryStorage.cpp index 2f8691066..6c32ba176 100644 --- a/Contractor/TemporaryStorage.cpp +++ b/Contractor/TemporaryStorage.cpp @@ -45,7 +45,7 @@ int TemporaryStorage::allocateSlot() { boost::mutex::scoped_lock lock(mutex); try { vectorOfStreamDatas.push_back(StreamData()); - //INFO("created new temporary file: " << vectorOfStreamDatas.back().pathToTemporaryFile); + //SimpleLogger().Write() << "created new temporary file: " << vectorOfStreamDatas.back().pathToTemporaryFile; } catch(boost::filesystem::filesystem_error & e) { abort(e); } diff --git a/Contractor/TemporaryStorage.h b/Contractor/TemporaryStorage.h index 066d22de5..feebc3552 100644 --- a/Contractor/TemporaryStorage.h +++ b/Contractor/TemporaryStorage.h @@ -32,6 +32,7 @@ #include #include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" #include "../typedefs.h" //This is one big workaround for latest boost renaming woes. diff --git a/DataStructures/NodeInformationHelpDesk.h b/DataStructures/NodeInformationHelpDesk.h index 773a29e51..37bead56f 100644 --- a/DataStructures/NodeInformationHelpDesk.h +++ b/DataStructures/NodeInformationHelpDesk.h @@ -136,7 +136,7 @@ private: throw OSRMException("edges file not found"); } - DEBUG("Loading node data"); + SimpleLogger().Write(logDEBUG) << "Loading node data"; NodeInfo b; while(!nodes_input_stream.eof()) { nodes_input_stream.read((char *)&b, sizeof(NodeInfo)); @@ -145,7 +145,7 @@ private: std::vector<_Coordinate>(coordinateVector).swap(coordinateVector); nodes_input_stream.close(); - DEBUG("Loading edge data"); + SimpleLogger().Write(logDEBUG) << "Loading edge data"; unsigned numberOfOrigEdges(0); edges_input_stream.read((char*)&numberOfOrigEdges, sizeof(unsigned)); origEdgeData_viaNode.resize(numberOfOrigEdges); @@ -163,8 +163,8 @@ private: origEdgeData_turnInstruction[i] = deserialized_originalEdgeData.turnInstruction; } edges_input_stream.close(); - DEBUG("Loaded " << numberOfOrigEdges << " orig edges"); - DEBUG("Opening NN indices"); + SimpleLogger().Write(logDEBUG) << "Loaded " << numberOfOrigEdges << " orig edges"; + SimpleLogger().Write(logDEBUG) << "Opening NN indices"; } std::vector<_Coordinate> coordinateVector; diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 7504cbaa9..4e95c1630 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -21,6 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef STATICGRAPH_H_INCLUDED #define STATICGRAPH_H_INCLUDED +#include "../Util/SimpleLogger.h" #include "../typedefs.h" #include @@ -99,12 +100,17 @@ public: if(data.shortcut) { unsigned eid2 = FindEdgeInEitherDirection(u, data.id); if(eid2 == UINT_MAX) { - DEBUG("cannot find first segment of edge (" << u << "," << data.id << "," << v << ")"); + SimpleLogger().Write(logWARNING) << + "cannot find first segment of edge (" << + u << "," << data.id << "," << v << ")"; + data.shortcut = false; } eid2 = FindEdgeInEitherDirection(data.id, v); if(eid2 == UINT_MAX) { - DEBUG("cannot find second segment of edge (" << u << "," << data.id << "," << v << ")"); + SimpleLogger().Write(logWARNING) << + "cannot find second segment of edge (" << + u << "," << data.id << "," << v << ")"; data.shortcut = false; } } diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index 2defee25f..02b372403 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "PhantomNodes.h" #include "DeallocatingVector.h" #include "HilbertValue.h" +#include "../Util/SimpleLogger.h" #include "../Util/TimingUtil.h" #include "../typedefs.h" @@ -287,7 +288,10 @@ public: : m_element_count(input_data_vector.size()), m_leaf_node_filename(leaf_node_filename) { - INFO("constructing r-tree of " << m_element_count << " elements"); + SimpleLogger().Write() << + "constructing r-tree of " << m_element_count << + " elements"; + double time1 = get_timestamp(); std::vector input_wrapper_vector(m_element_count); @@ -394,7 +398,8 @@ public: //close tree node file. tree_node_file.close(); double time2 = get_timestamp(); - INFO("finished r-tree construction in " << (time2-time1) << " seconds"); + SimpleLogger().Write() << + "finished r-tree construction in " << (time2-time1) << " seconds"; } //Read-only operation for queries @@ -406,7 +411,7 @@ public: std::ifstream tree_node_file(node_filename.c_str(), std::ios::binary); uint32_t tree_size = 0; tree_node_file.read((char*)&tree_size, sizeof(uint32_t)); - //INFO("reading " << tree_size << " tree nodes in " << (sizeof(TreeNode)*tree_size) << " bytes"); + //SimpleLogger().Write() << "reading " << tree_size << " tree nodes in " << (sizeof(TreeNode)*tree_size) << " bytes"; m_search_tree.resize(tree_size); tree_node_file.read((char*)&m_search_tree[0], sizeof(TreeNode)*tree_size); tree_node_file.close(); @@ -416,8 +421,8 @@ public: leaf_node_file.read((char*)&m_element_count, sizeof(uint64_t)); leaf_node_file.close(); - //INFO( tree_size << " nodes in search tree"); - //INFO( m_element_count << " elements in leafs"); + //SimpleLogger().Write() << tree_size << " nodes in search tree"; + //SimpleLogger().Write() << m_element_count << " elements in leafs"; } /* inline void FindKNearestPhantomNodesForCoordinate( @@ -432,7 +437,7 @@ public: uint32_t io_count = 0; uint32_t explored_tree_nodes_count = 0; - INFO("searching for coordinate " << input_coordinate); + SimpleLogger().Write() << "searching for coordinate " << input_coordinate; double min_dist = DBL_MAX; double min_max_dist = DBL_MAX; bool found_a_nearest_edge = false; @@ -561,7 +566,7 @@ public: result_phantom_node.location.lat = input_coordinate.lat; } - INFO("mindist: " << min_distphantom_node.isBidirected() ? "yes" : "no") ); + SimpleLogger().Write() << "mindist: " << min_distphantom_node.isBidirected() ? "yes" : "no"); return found_a_nearest_edge; } @@ -578,7 +583,7 @@ public: uint32_t io_count = 0; uint32_t explored_tree_nodes_count = 0; - //INFO("searching for coordinate " << input_coordinate); + //SimpleLogger().Write() << "searching for coordinate " << input_coordinate; double min_dist = DBL_MAX; double min_max_dist = DBL_MAX; bool found_a_nearest_edge = false; @@ -609,7 +614,7 @@ public: LeafNode current_leaf_node; LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node); ++io_count; - //INFO("checking " << current_leaf_node.object_count << " elements"); + //SimpleLogger().Write() << "checking " << current_leaf_node.object_count << " elements"; for(uint32_t i = 0; i < current_leaf_node.object_count; ++i) { DataT & current_edge = current_leaf_node.objects[i]; if(ignore_tiny_components && current_edge.belongsToTinyComponent) { @@ -664,15 +669,15 @@ public: ) ) { BOOST_ASSERT_MSG(current_edge.id != result_phantom_node.edgeBasedNode, "IDs not different"); - //INFO("found bidirected edge on nodes " << current_edge.id << " and " << result_phantom_node.edgeBasedNode); + //SimpleLogger().Write() << "found bidirected edge on nodes " << current_edge.id << " and " << result_phantom_node.edgeBasedNode; result_phantom_node.weight2 = current_edge.weight; if(current_edge.id < result_phantom_node.edgeBasedNode) { result_phantom_node.edgeBasedNode = current_edge.id; std::swap(result_phantom_node.weight1, result_phantom_node.weight2); std::swap(current_end_coordinate, current_start_coordinate); - // INFO("case 2"); + // SimpleLogger().Write() <<"case 2"; } - //INFO("w1: " << result_phantom_node.weight1 << ", w2: " << result_phantom_node.weight2); + //SimpleLogger().Write() << "w1: " << result_phantom_node.weight1 << ", w2: " << result_phantom_node.weight2; } } } else { @@ -732,7 +737,7 @@ private: } if(!thread_local_rtree_stream->good()) { thread_local_rtree_stream->clear(std::ios::goodbit); - DEBUG("Resetting stale filestream"); + SimpleLogger().Write(logDEBUG) << "Resetting stale filestream"; } uint64_t seek_pos = sizeof(uint64_t) + leaf_id*sizeof(LeafNode); thread_local_rtree_stream->seekg(seek_pos); diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index e027c3704..692dc31cb 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -123,7 +123,7 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev // || std::string::npos != string0.find(string1+" ;") // || std::string::npos != string0.find("; "+string1) // ){ -// INFO("->next correct: " << string0 << " contains " << string1); +// SimpleLogger().Write() << "->next correct: " << string0 << " contains " << string1; // for(; lastTurn != i; ++lastTurn) // pathDescription[lastTurn].nameID = pathDescription[i].nameID; // pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn; @@ -132,7 +132,7 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev // || std::string::npos != string1.find(string0+" ;") // || std::string::npos != string1.find("; "+string0) // ){ -// INFO("->prev correct: " << string1 << " contains " << string0); +// SimpleLogger().Write() << "->prev correct: " << string1 << " contains " << string0; // pathDescription[i].nameID = pathDescription[i-1].nameID; // pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn; // } @@ -153,24 +153,24 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev if(TurnInstructionsClass::NoTurn != pathDescription[i].turnInstruction) { - //INFO("Turn after " << lengthOfSegment << "m into way with name id " << segment.nameID); + //SimpleLogger().Write() << "Turn after " << lengthOfSegment << "m into way with name id " << segment.nameID; assert(pathDescription[i].necessary); lengthOfSegment = 0; durationOfSegment = 0; indexOfSegmentBegin = i; } } - // INFO("#segs: " << pathDescription.size()); + // SimpleLogger().Write() << "#segs: " << pathDescription.size(); //Post-processing to remove empty or nearly empty path segments if(FLT_EPSILON > pathDescription.back().length) { - // INFO("#segs: " << pathDescription.size() << ", last ratio: " << targetPhantom.ratio << ", length: " << pathDescription.back().length); + // SimpleLogger().Write() << "#segs: " << pathDescription.size() << ", last ratio: " << targetPhantom.ratio << ", length: " << pathDescription.back().length; if(pathDescription.size() > 2){ pathDescription.pop_back(); pathDescription.back().necessary = true; pathDescription.back().turnInstruction = TurnInstructions.NoTurn; targetPhantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->nameID; - // INFO("Deleting last turn instruction"); + // SimpleLogger().Write() << "Deleting last turn instruction"; } } else { pathDescription[indexOfSegmentBegin].duration *= (1.-targetPhantom.ratio); @@ -182,7 +182,7 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev pathDescription[0].turnInstruction = TurnInstructions.HeadOn; pathDescription[0].necessary = true; startPhantom.nodeBasedEdgeNameID = pathDescription[0].nameID; - // INFO("Deleting first turn instruction, ratio: " << startPhantom.ratio << ", length: " << pathDescription[0].length); + // SimpleLogger().Write() << "Deleting first turn instruction, ratio: " << startPhantom.ratio << ", length: " << pathDescription[0].length; } } else { pathDescription[0].duration *= startPhantom.ratio; diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index e54752d16..36071e492 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -27,6 +27,7 @@ #include "../DataStructures/SearchEngine.h" #include "../DataStructures/SegmentInformation.h" #include "../DataStructures/TurnInstructions.h" +#include "../Util/SimpleLogger.h" #include "../typedefs.h" #include diff --git a/Extractor/BaseParser.cpp b/Extractor/BaseParser.cpp index b5ba3e614..cf5530a4d 100644 --- a/Extractor/BaseParser.cpp +++ b/Extractor/BaseParser.cpp @@ -37,9 +37,9 @@ void BaseParser::ReadUseRestrictionsSetting() { use_turn_restrictions = lua_toboolean(luaState, -1); } if( use_turn_restrictions ) { - INFO("Using turn restrictions" ); + SimpleLogger().Write() << "Using turn restrictions"; } else { - INFO("Ignoring turn restrictions" ); + SimpleLogger().Write() << "Ignoring turn restrictions"; } } @@ -51,12 +51,12 @@ void BaseParser::ReadRestrictionExceptions() { "get_exceptions", boost::ref(restriction_exceptions) ); - INFO("Found " << restriction_exceptions.size() << " exceptions to turn restriction"); + SimpleLogger().Write() << "Found " << restriction_exceptions.size() << " exceptions to turn restriction"; BOOST_FOREACH(const std::string & str, restriction_exceptions) { - INFO(" " << str); + SimpleLogger().Write() << " " << str; } } else { - INFO("Found no exceptions to turn restrictions"); + SimpleLogger().Write() << "Found no exceptions to turn restrictions"; } } diff --git a/Extractor/BaseParser.h b/Extractor/BaseParser.h index e65678fe4..64228b53d 100644 --- a/Extractor/BaseParser.h +++ b/Extractor/BaseParser.h @@ -24,6 +24,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "ExtractorCallbacks.h" #include "ScriptingEnvironment.h" #include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" extern "C" { #include diff --git a/Extractor/ExtractionContainers.cpp b/Extractor/ExtractionContainers.cpp index 292e994cf..255d545e4 100644 --- a/Extractor/ExtractionContainers.cpp +++ b/Extractor/ExtractionContainers.cpp @@ -117,7 +117,7 @@ void ExtractionContainers::PrepareData(const std::string & output_file_name, con ++restrictionsIT; } std::cout << "ok, after " << get_timestamp() - time << "s" << std::endl; - INFO("usable restrictions: " << usableRestrictionsCounter ); + SimpleLogger().Write() << "usable restrictions: " << usableRestrictionsCounter; //serialize restrictions std::ofstream restrictionsOutstream; restrictionsOutstream.open(restrictionsFileName.c_str(), std::ios::binary); @@ -298,7 +298,7 @@ void ExtractionContainers::PrepareData(const std::string & output_file_name, con // addressOutFile.close(); // cout << "ok, after " << get_timestamp() - time << "s" << endl; - INFO("Processed " << usedNodeCounter << " nodes and " << usedEdgeCounter << " edges"); + SimpleLogger().Write() << "Processed " << usedNodeCounter << " nodes and " << usedEdgeCounter << " edges"; } catch ( const std::exception& e ) { diff --git a/Extractor/ExtractionContainers.h b/Extractor/ExtractionContainers.h index ded5c3aad..96b8ba357 100644 --- a/Extractor/ExtractionContainers.h +++ b/Extractor/ExtractionContainers.h @@ -22,6 +22,7 @@ #define EXTRACTIONCONTAINERS_H_ #include "ExtractorStructs.h" +#include "../Util/SimpleLogger.h" #include "../Util/TimingUtil.h" #include "../Util/UUID.h" diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 8c28f855d..f2f53a02b 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -45,7 +45,9 @@ bool ExtractorCallbacks::restrictionFunction(const _RawRestrictionContainer &r) void ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) { if((0 < parsed_way.speed) || (0 < parsed_way.duration)) { //Only true if the way is specified by the speed profile if(UINT_MAX == parsed_way.id){ - DEBUG("found bogus way with id: " << parsed_way.id << " of size " << parsed_way.path.size()); + SimpleLogger().Write(logDEBUG) << + "found bogus way with id: " << parsed_way.id << + " of size " << parsed_way.path.size(); return; } @@ -55,7 +57,8 @@ void ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) { } if(FLT_EPSILON >= fabs(-1. - parsed_way.speed)){ - DEBUG("found way with bogus speed, id: " << parsed_way.id); + SimpleLogger().Write(logDEBUG) << + "found way with bogus speed, id: " << parsed_way.id; return; } diff --git a/Extractor/PBFParser.cpp b/Extractor/PBFParser.cpp index 92338e14a..6221c6f26 100644 --- a/Extractor/PBFParser.cpp +++ b/Extractor/PBFParser.cpp @@ -49,9 +49,10 @@ PBFParser::~PBFParser() { } google::protobuf::ShutdownProtobufLibrary(); -#ifndef NDEBUG - DEBUG("parsed " << blockCount << " blocks from pbf with " << groupCount << " groups"); -#endif + SimpleLogger().Write(logDEBUG) << + "parsed " << blockCount << + " blocks from pbf with " << groupCount << + " groups"; } inline bool PBFParser::ReadHeader() { @@ -108,7 +109,7 @@ inline void PBFParser::ParseData() { _ThreadData *threadData; threadDataQueue->wait_and_pop(threadData); if( NULL==threadData ) { - INFO("Parse Data Thread Finished"); + SimpleLogger().Write() << "Parse Data Thread Finished"; threadDataQueue->push(NULL); // Signal end of data for other threads break; } diff --git a/Extractor/PBFParser.h b/Extractor/PBFParser.h index edf5cd012..ec5035f3d 100644 --- a/Extractor/PBFParser.h +++ b/Extractor/PBFParser.h @@ -29,6 +29,7 @@ #include "../Util/MachineInfo.h" #include "../Util/OpenMPWrapper.h" #include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" #include "../typedefs.h" #include diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index 0b76749dd..fba59f89d 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -22,7 +22,7 @@ ScriptingEnvironment::ScriptingEnvironment() {} ScriptingEnvironment::ScriptingEnvironment(const char * fileName) { - INFO("Using script " << fileName); + SimpleLogger().Write() << "Using script " << fileName; // Create a new lua state for(int i = 0; i < omp_get_max_threads(); ++i) { diff --git a/Extractor/ScriptingEnvironment.h b/Extractor/ScriptingEnvironment.h index 315d84318..fc4b97e1a 100644 --- a/Extractor/ScriptingEnvironment.h +++ b/Extractor/ScriptingEnvironment.h @@ -27,6 +27,7 @@ #include "../Util/LuaUtil.h" #include "../Util/OpenMPWrapper.h" #include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" #include "../typedefs.h" #include diff --git a/Extractor/XMLParser.cpp b/Extractor/XMLParser.cpp index 6ce834335..2ab6e7335 100644 --- a/Extractor/XMLParser.cpp +++ b/Extractor/XMLParser.cpp @@ -27,7 +27,9 @@ #include XMLParser::XMLParser(const char * filename, ExtractorCallbacks* ec, ScriptingEnvironment& se) : BaseParser(ec, se) { - WARN("Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf"); + SimpleLogger().Write(logWARNING) << + "Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf"; + inputReader = inputReaderFactory(filename); } diff --git a/Extractor/XMLParser.h b/Extractor/XMLParser.h index 39070f470..51b7b1b1e 100644 --- a/Extractor/XMLParser.h +++ b/Extractor/XMLParser.h @@ -23,6 +23,7 @@ #include "BaseParser.h" #include "../DataStructures/Coordinate.h" +#include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" #include "../typedefs.h" diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index 13c9e025d..cbeae3fe8 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -33,6 +33,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Descriptors/GPXDescriptor.h" #include "../Descriptors/JSONDescriptor.h" #include "../Server/DataStructures/QueryObjectsStorage.h" +#include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" #include @@ -90,14 +91,14 @@ public: std::vector phantomNodeVector(rawRoute.rawViaNodeCoordinates.size()); for(unsigned i = 0; i < rawRoute.rawViaNodeCoordinates.size(); ++i) { if(checksumOK && i < routeParameters.hints.size() && "" != routeParameters.hints[i]) { -// INFO("Decoding hint: " << routeParameters.hints[i] << " for location index " << i); +// SimpleLogger().Write() <<"Decoding hint: " << routeParameters.hints[i] << " for location index " << i; DecodeObjectFromBase64(routeParameters.hints[i], phantomNodeVector[i]); if(phantomNodeVector[i].isValid(nodeHelpDesk->getNumberOfNodes())) { -// INFO("Decoded hint " << i << " successfully"); +// SimpleLogger().Write() << "Decoded hint " << i << " successfully"; continue; } } -// INFO("Brute force lookup of coordinate " << i); +// SimpleLogger().Write() << "Brute force lookup of coordinate " << i; searchEnginePtr->FindPhantomNodeForCoordinate( rawRoute.rawViaNodeCoordinates[i], phantomNodeVector[i], routeParameters.zoomLevel); } @@ -108,7 +109,7 @@ public: rawRoute.segmentEndCoordinates.push_back(segmentPhantomNodes); } if( ( routeParameters.alternateRoute ) && (1 == rawRoute.segmentEndCoordinates.size()) ) { -// INFO("Checking for alternative paths"); +// SimpleLogger().Write() << "Checking for alternative paths"; searchEnginePtr->alternativePaths(rawRoute.segmentEndCoordinates[0], rawRoute); } else { @@ -117,7 +118,7 @@ public: if(INT_MAX == rawRoute.lengthOfShortestPath ) { - DEBUG( "Error occurred, single path not found" ); + SimpleLogger().Write(logDEBUG) << "Error occurred, single path not found"; } reply.status = http::Reply::ok; @@ -152,10 +153,10 @@ public: PhantomNodes phantomNodes; phantomNodes.startPhantom = rawRoute.segmentEndCoordinates[0].startPhantom; -// INFO("Start location: " << phantomNodes.startPhantom.location) +// SimpleLogger().Write() << "Start location: " << phantomNodes.startPhantom.location; phantomNodes.targetPhantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].targetPhantom; -// INFO("TargetLocation: " << phantomNodes.targetPhantom.location); -// INFO("Number of segments: " << rawRoute.segmentEndCoordinates.size()); +// SimpleLogger().Write() << "TargetLocation: " << phantomNodes.targetPhantom.location; +// SimpleLogger().Write() << "Number of segments: " << rawRoute.segmentEndCoordinates.size(); desc->SetConfig(descriptorConfig); desc->Run(reply, rawRoute, phantomNodes, *searchEnginePtr); diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index 8c3e53ef3..8b54a3de5 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -307,7 +307,7 @@ private: int aindex = 0; //compute forward sharing while( (packedAlternativePath[aindex] == packedShortestPath[aindex]) && (packedAlternativePath[aindex+1] == packedShortestPath[aindex+1]) ) { - // INFO("retrieving edge (" << packedAlternativePath[aindex] << "," << packedAlternativePath[aindex+1] << ")"); + // SimpleLogger().Write() << "retrieving edge (" << packedAlternativePath[aindex] << "," << packedAlternativePath[aindex+1] << ")"; typename SearchGraph::EdgeIterator edgeID = search_graph->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex+1]); sharing += search_graph->GetEdgeData(edgeID).distance; ++aindex; diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index caef97a96..67615a89d 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -25,6 +25,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Plugins/RawRouteData.h" #include "../Util/ContainerUtils.h" +#include "../Util/SimpleLogger.h" #include @@ -44,7 +45,7 @@ public: inline void RoutingStep(typename QueryDataT::QueryHeap & _forwardHeap, typename QueryDataT::QueryHeap & _backwardHeap, NodeID *middle, int *_upperbound, const int edgeBasedOffset, const bool forwardDirection) const { const NodeID node = _forwardHeap.DeleteMin(); const int distance = _forwardHeap.GetKey(node); - //INFO("Settled (" << _forwardHeap.GetData( node ).parent << "," << node << ")=" << distance); + //SimpleLogger().Write() << "Settled (" << _forwardHeap.GetData( node ).parent << "," << node << ")=" << distance; if(_backwardHeap.WasInserted(node) ){ const int newDistance = _backwardHeap.GetKey(node) + distance; if(newDistance < *_upperbound ){ diff --git a/Server/DataStructures/QueryObjectsStorage.cpp b/Server/DataStructures/QueryObjectsStorage.cpp index aa8956c1a..9373a5f9e 100644 --- a/Server/DataStructures/QueryObjectsStorage.cpp +++ b/Server/DataStructures/QueryObjectsStorage.cpp @@ -20,7 +20,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "QueryObjectsStorage.h" -#include "../../Util/GraphLoader.h" QueryObjectsStorage::QueryObjectsStorage( const std::string & hsgrPath, @@ -31,7 +30,7 @@ QueryObjectsStorage::QueryObjectsStorage( const std::string & namesPath, const std::string & timestampPath ) { - INFO("loading graph data"); + SimpleLogger().Write() << "loading graph data"; std::ifstream hsgrInStream(hsgrPath.c_str(), std::ios::binary); if(!hsgrInStream) { throw OSRMException("hsgr not found"); @@ -47,15 +46,17 @@ QueryObjectsStorage::QueryObjectsStorage( ); hsgrInStream.close(); - INFO("Data checksum is " << checkSum); + SimpleLogger().Write() << "Data checksum is " << checkSum; graph = new QueryGraph(nodeList, edgeList); assert(0 == nodeList.size()); assert(0 == edgeList.size()); if(timestampPath.length()) { - INFO("Loading Timestamp"); + SimpleLogger().Write() << "Loading Timestamp"; std::ifstream timestampInStream(timestampPath.c_str()); - if(!timestampInStream) { WARN(timestampPath << " not found"); } + if(!timestampInStream) { + SimpleLogger().Write(logWARNING) << timestampPath << " not found"; + } getline(timestampInStream, timestamp); timestampInStream.close(); @@ -67,7 +68,7 @@ QueryObjectsStorage::QueryObjectsStorage( timestamp.resize(25); } - INFO("Loading auxiliary information"); + SimpleLogger().Write() << "Loading auxiliary information"; //Init nearest neighbor data structure nodeHelpDesk = new NodeInformationHelpDesk( ramIndexPath, @@ -79,7 +80,7 @@ QueryObjectsStorage::QueryObjectsStorage( ); //deserialize street name list - INFO("Loading names index"); + SimpleLogger().Write() << "Loading names index"; std::ifstream namesInStream(namesPath.c_str(), std::ios::binary); if(!namesInStream) { throw OSRMException("names file not found"); @@ -97,7 +98,7 @@ QueryObjectsStorage::QueryObjectsStorage( } std::vector(names).swap(names); namesInStream.close(); - INFO("All query data structures loaded"); + SimpleLogger().Write() << "All query data structures loaded"; } QueryObjectsStorage::~QueryObjectsStorage() { diff --git a/Server/DataStructures/QueryObjectsStorage.h b/Server/DataStructures/QueryObjectsStorage.h index ebf4bef32..9d2429c0b 100644 --- a/Server/DataStructures/QueryObjectsStorage.h +++ b/Server/DataStructures/QueryObjectsStorage.h @@ -24,8 +24,9 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include - +#include "../../Util/GraphLoader.h" #include "../../Util/OSRMException.h" +#include "../../Util/SimpleLogger.h" #include "../../DataStructures/NodeInformationHelpDesk.h" #include "../../DataStructures/QueryEdge.h" #include "../../DataStructures/StaticGraph.h" diff --git a/Server/RequestHandler.h b/Server/RequestHandler.h index 0f91601ab..0105703b3 100644 --- a/Server/RequestHandler.h +++ b/Server/RequestHandler.h @@ -25,6 +25,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "BasicDatastructures.h" #include "../Library/OSRM.h" #include "../Plugins/RouteParameters.h" +#include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" #include "../typedefs.h" @@ -53,8 +54,8 @@ public: ltime=time(NULL); Tm=localtime(<ime); - INFO((Tm->tm_mday < 10 ? "0" : "" ) << Tm->tm_mday << "-" << (Tm->tm_mon+1 < 10 ? "0" : "" ) << (Tm->tm_mon+1) << "-" << 1900+Tm->tm_year << " " << (Tm->tm_hour < 10 ? "0" : "" ) << Tm->tm_hour << ":" << (Tm->tm_min < 10 ? "0" : "" ) << Tm->tm_min << ":" << (Tm->tm_sec < 10 ? "0" : "" ) << Tm->tm_sec << " " << - req.endpoint.to_string() << " " << req.referrer << ( 0 == req.referrer.length() ? "- " :" ") << req.agent << ( 0 == req.agent.length() ? "- " :" ") << req.uri ); + SimpleLogger().Write() << (Tm->tm_mday < 10 ? "0" : "" ) << Tm->tm_mday << "-" << (Tm->tm_mon+1 < 10 ? "0" : "" ) << (Tm->tm_mon+1) << "-" << 1900+Tm->tm_year << " " << (Tm->tm_hour < 10 ? "0" : "" ) << Tm->tm_hour << ":" << (Tm->tm_min < 10 ? "0" : "" ) << Tm->tm_min << ":" << (Tm->tm_sec < 10 ? "0" : "" ) << Tm->tm_sec << " " << + req.endpoint.to_string() << " " << req.referrer << ( 0 == req.referrer.length() ? "- " :" ") << req.agent << ( 0 == req.agent.length() ? "- " :" ") << req.uri; } RouteParameters routeParameters; @@ -84,7 +85,8 @@ public: } } catch(std::exception& e) { rep = http::Reply::stockReply(http::Reply::internalServerError); - WARN("[server error] code: " << e.what() << ", uri: " << req.uri); + SimpleLogger().Write(logWARNING) << + "[server error] code: " << e.what() << ", uri: " << req.uri; return; } }; diff --git a/Tools/componentAnalysis.cpp b/Tools/componentAnalysis.cpp index be7691c39..b196ddca3 100644 --- a/Tools/componentAnalysis.cpp +++ b/Tools/componentAnalysis.cpp @@ -29,6 +29,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Util/IniFile.h" #include "../Util/InputFileUtil.h" #include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" #include #include @@ -52,7 +53,7 @@ int main (int argument_count, char *argument_values[]) { return -1; } - INFO("Using restrictions from file: " << argument_values[2]); + SimpleLogger().Write() << "Using restrictions from file: " << argument_values[2]; std::ifstream restriction_ifstream(argument_values[2], std::ios::binary); if(!restriction_ifstream.good()) { throw OSRMException("Could not access files"); @@ -91,17 +92,16 @@ int main (int argument_count, char *argument_values[]) { ); input_stream.close(); - INFO( + SimpleLogger().Write() << restrictions_vector.size() << " restrictions, " << bollard_node_IDs_vector.size() << " bollard nodes, " << - traffic_light_node_IDs_vector.size() << " traffic lights" - ); + traffic_light_node_IDs_vector.size() << " traffic lights"; /*** * Building an edge-expanded graph from node-based input an turn restrictions */ - INFO("Starting SCC graph traversal"); + SimpleLogger().Write() << "Starting SCC graph traversal"; TarjanSCC * tarjan = new TarjanSCC ( node_based_node_count, edge_list, @@ -117,6 +117,6 @@ int main (int argument_count, char *argument_values[]) { std::vector<_Restriction>().swap(restrictions_vector); std::vector().swap(bollard_node_IDs_vector); std::vector().swap(traffic_light_node_IDs_vector); - INFO("finished component analysis"); + SimpleLogger().Write() << "finished component analysis"; return 0; } diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index 7069e64da..c3c9a5c44 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../DataStructures/ImportEdge.h" #include "../DataStructures/QueryNode.h" #include "../DataStructures/Restriction.h" +#include "../Util/SimpleLogger.h" #include "../Util/UUID.h" #include "../typedefs.h" @@ -64,10 +65,9 @@ NodeID readBinaryOSRMGraphFromStream( in.read((char *) &uuid_loaded, sizeof(UUID)); if( !uuid_loaded.TestGraphUtil(uuid_orig) ) { - WARN( + SimpleLogger().Write(logWARNING) << ".osrm was prepared with different build.\n" - "Reprocess to get rid of this warning." - ) + "Reprocess to get rid of this warning."; } NodeID n, source, target; @@ -75,7 +75,7 @@ NodeID readBinaryOSRMGraphFromStream( short dir;// direction (0 = open, 1 = forward, 2+ = open) ExternalNodeMap ext2IntNodeMap; in.read((char*)&n, sizeof(NodeID)); - INFO("Importing n = " << n << " nodes "); + SimpleLogger().Write() << "Importing n = " << n << " nodes "; _Node node; for (NodeID i=0; i(trafficLightNodes).swap(trafficLightNodes); in.read((char*)&m, sizeof(unsigned)); - INFO(" and " << m << " edges "); + SimpleLogger().Write() << " and " << m << " edges "; for(unsigned i = 0; i < inputRestrictions.size(); ++i) { ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(inputRestrictions[i].fromNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped from Node of restriction"); + SimpleLogger().Write(logDEBUG) << "Unmapped from Node of restriction"; continue; } @@ -104,14 +104,14 @@ NodeID readBinaryOSRMGraphFromStream( intNodeID = ext2IntNodeMap.find(inputRestrictions[i].viaNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped via node of restriction"); + SimpleLogger().Write(logDEBUG) << "Unmapped via node of restriction"; continue; } inputRestrictions[i].viaNode = intNodeID->second; intNodeID = ext2IntNodeMap.find(inputRestrictions[i].toNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped to node of restriction"); + SimpleLogger().Write(logDEBUG) << "Unmapped to node of restriction"; continue; } inputRestrictions[i].toNode = intNodeID->second; @@ -152,7 +152,8 @@ NodeID readBinaryOSRMGraphFromStream( ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source); if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { #ifndef NDEBUG - WARN(" unresolved source NodeID: " << source ); + SimpleLogger().Write(logWARNING) << + " unresolved source NodeID: " << source; #endif continue; } @@ -160,7 +161,8 @@ NodeID readBinaryOSRMGraphFromStream( intNodeID = ext2IntNodeMap.find(target); if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { #ifndef NDEBUG - WARN("unresolved target NodeID : " << target ); + SimpleLogger().Write(logWARNING) << + "unresolved target NodeID : " << target; #endif continue; } @@ -211,7 +213,7 @@ NodeID readBinaryOSRMGraphFromStream( typename std::vector::iterator newEnd = std::remove_if(edgeList.begin(), edgeList.end(), _ExcessRemover()); ext2IntNodeMap.clear(); std::vector(edgeList.begin(), newEnd).swap(edgeList); //remove excess candidates. - INFO("Graph loaded ok and has " << edgeList.size() << " edges"); + SimpleLogger().Write() << "Graph loaded ok and has " << edgeList.size() << " edges"; return n; } template @@ -221,14 +223,14 @@ NodeID readDTMPGraphFromStream(std::istream &in, std::vector& edgeList, s int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open) ExternalNodeMap ext2IntNodeMap; in >> n; - DEBUG("Importing n = " << n << " nodes "); + SimpleLogger().Write(logDEBUG) << "Importing n = " << n << " nodes "; for (NodeID i=0; i> id >> ycoord >> xcoord; int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id)); ext2IntNodeMap.insert(std::make_pair(id, i)); } in >> m; - DEBUG(" and " << m << " edges"); + SimpleLogger().Write(logDEBUG) << " and " << m << " edges"; edgeList.reserve(m); for (EdgeID i=0; i& edgeList, s } assert(length > 0); assert(weight > 0); - if(dir <0 || dir > 2) - WARN("direction bogus: " << dir); + if(dir <0 || dir > 2) { + SimpleLogger().Write(logWARNING) << "direction bogus: " << dir; + } assert(0<=dir && dir<=2); bool forward = true; @@ -349,9 +352,10 @@ NodeID readDDSGGraphFromStream(std::istream &in, std::vector& edgeList, s in >> d; in >> n; in >> m; -#ifndef DEBUG - std::cout << "expecting " << n << " nodes and " << m << " edges ..." << flush; -#endif + + SimpleLogger().Write(logDEBUG) << + "expecting " << n << " nodes and " << m << " edges ..."; + edgeList.reserve(m); for (EdgeID i=0; i edgeList; int main (int argc, char *argv[]) { try { + LogPolicy::GetInstance().Unmute(); if(argc < 3) { - std::cerr << - "usage: \n" << - argv[0] << " []" << std::endl; + SimpleLogger().Write(logWARNING) << + "usage: \n" << + argv[0] << " []"; return -1; } @@ -75,8 +77,8 @@ int main (int argc, char *argv[]) { number_of_threads = rawNumber; } omp_set_num_threads(number_of_threads); - - INFO("Using restrictions from file: " << argv[2]); + LogPolicy::GetInstance().Unmute(); + SimpleLogger().Write() << "Using restrictions from file: " << argv[2]; std::ifstream restrictionsInstream(argv[2], std::ios::binary); if(!restrictionsInstream.good()) { std::cerr << @@ -88,10 +90,9 @@ int main (int argc, char *argv[]) { unsigned usableRestrictionsCounter(0); restrictionsInstream.read((char*)&uuid_loaded, sizeof(UUID)); if( !uuid_loaded.TestPrepare(uuid_orig) ) { - WARN( - ".restrictions was prepared with different build.\n" - "Reprocess to get rid of this warning." - ); + SimpleLogger().Write(logWARNING) << + ".restrictions was prepared with different build.\n" + "Reprocess to get rid of this warning."; } restrictionsInstream.read((char*)&usableRestrictionsCounter, sizeof(unsigned)); @@ -129,7 +130,10 @@ int main (int argc, char *argv[]) { luaAddScriptFolderToLoadPath( myLuaState, (argc > 3 ? argv[3] : "profile.lua") ); // Now call our function in a lua script - INFO("Parsing speedprofile from " << (argc > 3 ? argv[3] : "profile.lua") ); + SimpleLogger().Write() << + "Parsing speedprofile from " << + (argc > 3 ? argv[3] : "profile.lua"); + if(0 != luaL_dofile(myLuaState, (argc > 3 ? argv[3] : "profile.lua") )) { std::cerr << lua_tostring(myLuaState,-1) << @@ -162,7 +166,14 @@ int main (int argc, char *argv[]) { std::vector edgeList; NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternalNodeMapping, inputRestrictions); in.close(); - INFO(inputRestrictions.size() << " restrictions, " << bollardNodes.size() << " bollard nodes, " << trafficLightNodes.size() << " traffic lights"); + SimpleLogger().Write() << + inputRestrictions.size() << + " restrictions, " << + bollardNodes.size() << + " bollard nodes, " << + trafficLightNodes.size() << + " traffic lights"; + if(0 == edgeList.size()) { std::cerr << "The input data is broken. " @@ -175,7 +186,7 @@ int main (int argc, char *argv[]) { * Building an edge-expanded graph from node-based input an turn restrictions */ - INFO("Generating edge-expanded graph representation"); + SimpleLogger().Write() << "Generating edge-expanded graph representation"; EdgeBasedGraphFactory * edgeBasedGraphFactory = new EdgeBasedGraphFactory (nodeBasedNodeNumber, edgeList, bollardNodes, trafficLightNodes, inputRestrictions, internalToExternalNodeMapping, speedProfile); std::vector().swap(edgeList); edgeBasedGraphFactory->Run(edgeOut.c_str(), myLuaState); @@ -193,7 +204,7 @@ int main (int argc, char *argv[]) { * Writing info on original (node-based) nodes */ - INFO("writing node map ..."); + SimpleLogger().Write() << "writing node map ..."; std::ofstream mapOutFile(nodeOut.c_str(), std::ios::binary); mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo)); mapOutFile.close(); @@ -205,7 +216,7 @@ int main (int argc, char *argv[]) { * Building grid-like nearest-neighbor data structure */ - INFO("building r-tree ..."); + SimpleLogger().Write() << "building r-tree ..."; StaticRTree * rtree = new StaticRTree( nodeBasedEdgeList, @@ -216,17 +227,20 @@ int main (int argc, char *argv[]) { IteratorbasedCRC32 > crc32; unsigned crc32OfNodeBasedEdgeList = crc32(nodeBasedEdgeList.begin(), nodeBasedEdgeList.end() ); nodeBasedEdgeList.clear(); - INFO("CRC32 based checksum is " << crc32OfNodeBasedEdgeList); + SimpleLogger().Write() << "CRC32: " << crc32OfNodeBasedEdgeList; /*** * Contracting the edge-expanded graph */ - INFO("initializing contractor"); + SimpleLogger().Write() << "initializing contractor"; Contractor* contractor = new Contractor( edgeBasedNodeNumber, edgeBasedEdgeList ); double contractionStartedTimestamp(get_timestamp()); contractor->Run(); - INFO("Contraction took " << get_timestamp() - contractionStartedTimestamp << " sec"); + SimpleLogger().Write() << + "Contraction took " << + (get_timestamp() - contractionStartedTimestamp) << + " sec"; DeallocatingVector< QueryEdge > contractedEdgeList; contractor->GetEdges( contractedEdgeList ); @@ -236,11 +250,15 @@ int main (int argc, char *argv[]) { * Sorting contracted edges in a way that the static query graph can read some in in-place. */ - INFO("Building Node Array"); + SimpleLogger().Write() << "Building Node Array"; std::sort(contractedEdgeList.begin(), contractedEdgeList.end()); unsigned numberOfNodes = 0; unsigned numberOfEdges = contractedEdgeList.size(); - INFO("Serializing compacted graph of " << numberOfEdges << " edges"); + SimpleLogger().Write() << + "Serializing compacted graph of " << + numberOfEdges << + " edges"; + std::ofstream hsgr_output_stream(graphOut.c_str(), std::ios::binary); hsgr_output_stream.write((char*)&uuid_orig, sizeof(UUID) ); BOOST_FOREACH(const QueryEdge & edge, contractedEdgeList) { @@ -282,13 +300,15 @@ int main (int argc, char *argv[]) { currentEdge.target = contractedEdgeList[edge].target; currentEdge.data = contractedEdgeList[edge].data; if(currentEdge.data.distance <= 0) { - INFO("Edge: " << i << ",source: " << contractedEdgeList[edge].source << ", target: " << contractedEdgeList[edge].target << ", dist: " << currentEdge.data.distance); - std::cerr << - "Failed at edges of node " << - node << - " of " << - numberOfNodes << - std::endl; + SimpleLogger().Write(logWARNING) << + "Edge: " << i << + ",source: " << contractedEdgeList[edge].source << + ", target: " << contractedEdgeList[edge].target << + ", dist: " << currentEdge.data.distance; + + SimpleLogger().Write(logWARNING) << + "Failed at edges of node " << node << + " of " << numberOfNodes; return -1; } //Serialize edges @@ -298,15 +318,22 @@ int main (int argc, char *argv[]) { } } double endTime = (get_timestamp() - startupTime); - INFO("Expansion : " << (nodeBasedNodeNumber/expansionHasFinishedTime) << " nodes/sec and "<< (edgeBasedNodeNumber/expansionHasFinishedTime) << " edges/sec"); - INFO("Contraction: " << (edgeBasedNodeNumber/expansionHasFinishedTime) << " nodes/sec and "<< usedEdgeCounter/endTime << " edges/sec"); + SimpleLogger().Write() << "Expansion : " << + (nodeBasedNodeNumber/expansionHasFinishedTime) << " nodes/sec and " << + (edgeBasedNodeNumber/expansionHasFinishedTime) << " edges/sec"; + + SimpleLogger().Write() << "Contraction: " << + (edgeBasedNodeNumber/expansionHasFinishedTime) << " nodes/sec and " << + usedEdgeCounter/endTime << " edges/sec"; hsgr_output_stream.close(); //cleanedEdgeList.clear(); _nodes.clear(); - INFO("finished preprocessing"); + SimpleLogger().Write() << "finished preprocessing"; } catch ( const std::exception &e ) { - std::cerr << "Exception occured: " << e.what() << std::endl; + SimpleLogger().Write(logWARNING) << + "Exception occured: " << e.what() << std::endl; + return -1; } return 0; diff --git a/extractor.cpp b/extractor.cpp index 182545029..29296f919 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -28,6 +28,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "Util/MachineInfo.h" #include "Util/OpenMPWrapper.h" #include "Util/OSRMException.h" +#include "Util/SimpleLogger.h" #include "Util/StringUtil.h" #include "Util/UUID.h" #include "typedefs.h" @@ -43,14 +44,14 @@ UUID uuid; int main (int argc, char *argv[]) { try { + LogPolicy::GetInstance().Unmute(); double startup_time = get_timestamp(); if(argc < 2) { - std::cerr << + SimpleLogger().Write(logWARNING) << "usage: \n" << argv[0] << - " []" << - std::endl; + " []"; return -1; } @@ -60,16 +61,14 @@ int main (int argc, char *argv[]) { unsigned number_of_threads = omp_get_num_procs(); if(testDataFile("extractor.ini")) { IniFile extractorConfig("extractor.ini"); - INFO("2"); unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads")); - INFO("3"); if( rawNumber != 0 && rawNumber <= number_of_threads) { number_of_threads = rawNumber; } } omp_set_num_threads(number_of_threads); - INFO("extracting data from input file " << argv[1]); + SimpleLogger().Write() << "extracting data from input file " << argv[1]; bool file_has_pbf_format(false); std::string output_file_name(argv[1]); std::string restrictionsFileName(argv[1]); @@ -103,7 +102,7 @@ int main (int argc, char *argv[]) { unsigned amountOfRAM = 1; unsigned installedRAM = GetPhysicalmemory(); if(installedRAM < 2048264) { - WARN("Machine has less than 2GB RAM."); + SimpleLogger().Write(logWARNING) << "Machine has less than 2GB RAM."; } StringMap stringMap; @@ -121,30 +120,29 @@ int main (int argc, char *argv[]) { if(!parser->ReadHeader()) { throw OSRMException("Parser not initialized!"); } - INFO("Parsing in progress.."); + SimpleLogger().Write() << "Parsing in progress.."; double parsing_start_time = get_timestamp(); parser->Parse(); - INFO("Parsing finished after " << + SimpleLogger().Write() << "Parsing finished after " << (get_timestamp() - parsing_start_time) << - " seconds" - ); + " seconds"; externalMemory.PrepareData(output_file_name, restrictionsFileName, amountOfRAM); delete parser; delete extractCallBacks; - INFO("extraction finished after " << get_timestamp() - startup_time << "s"); + SimpleLogger().Write() << + "extraction finished after " << get_timestamp() - startup_time << + "s"; - std::cout << - "\nRun:\n" << - "./osrm-prepare " << + SimpleLogger().Write() << "\nRun:\n./osrm-prepare " << output_file_name << " " << restrictionsFileName << std::endl; } catch(std::exception & e) { - INFO("unhandled exception: " << e.what()); + SimpleLogger().Write(logWARNING) << "unhandled exception: " << e.what(); return -1; } return 0; diff --git a/routed.cpp b/routed.cpp index bd916266a..9f45149e9 100644 --- a/routed.cpp +++ b/routed.cpp @@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "Util/IniFile.h" #include "Util/InputFileUtil.h" #include "Util/OpenMPWrapper.h" +#include "Util/SimpleLogger.h" #include "Util/UUID.h" #ifdef __linux__ @@ -63,7 +64,7 @@ BOOL WINAPI console_ctrl_handler(DWORD ctrl_type) int main (int argc, char * argv[]) { #ifdef __linux__ if(!mlockall(MCL_CURRENT | MCL_FUTURE)) - WARN("Process " << argv[0] << "could not be locked to RAM"); + SimpleLogger().Write(logWARNING) << "Process " << argv[0] << "could not be locked to RAM"; #endif #ifdef __linux__ @@ -122,7 +123,7 @@ int main (int argc, char * argv[]) { std::cout << "[server] stopping threads" << std::endl; if(!t.timed_join(boost::posix_time::seconds(2))) { -// INFO("Threads did not finish within 2 seconds. Hard abort!"); + SimpleLogger().Write(logDEBUG) << "Threads did not finish within 2 seconds. Hard abort!"; } std::cout << "[server] freeing objects" << std::endl; diff --git a/typedefs.h b/typedefs.h index bf0c731d0..b98783334 100644 --- a/typedefs.h +++ b/typedefs.h @@ -33,15 +33,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #endif #include - -#define INFO(x) do {std::cout << "[i " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); -#define WARN(x) do {std::cerr << "[? " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); - -#ifdef NDEBUG -#define DEBUG(x) -#else -#define DEBUG(x) do {std::cout << "[d " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); -#endif +#include #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -55,7 +47,6 @@ digitT round(digitT x) { } #endif - typedef unsigned int NodeID; typedef unsigned int EdgeID; typedef unsigned int EdgeWeight;