Changed PNS logging routine to wxLogTrace

This commit is contained in:
Maciej Suminski 2016-08-17 16:00:21 +02:00
parent 9f0b42cb35
commit 78050c05e2
17 changed files with 52 additions and 118 deletions

View File

@ -41,8 +41,6 @@
#include "length_tuner_tool.h"
#include "trace.h"
using namespace KIGFX;
using boost::optional;

View File

@ -22,8 +22,6 @@
#include <class_board_item.h>
#include <class_netinfo.h>
#include "trace.h"
#include "pns_node.h"
#include "pns_walkaround.h"
#include "pns_shove.h"

View File

@ -22,8 +22,6 @@
#include <base_units.h> // God forgive me doing this...
#include "trace.h"
#include "pns_node.h"
#include "pns_itemset.h"
#include "pns_topology.h"

View File

@ -112,7 +112,7 @@ bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
aStartItem->Unmark( MK_LOCKED );
TRACE( 2, "StartDragging: item %p [kind %d]", aStartItem % aStartItem->Kind() );
wxLogTrace( "PNS", "StartDragging: item %p [kind %d]", aStartItem, aStartItem->Kind() );
switch( aStartItem->Kind() )
{

View File

@ -26,8 +26,6 @@
#include <geometry/shape.h>
#include <geometry/shape_line_chain.h>
#include "trace.h"
#include "pns_layerset.h"
class BOARD_CONNECTED_ITEM;

View File

@ -120,8 +120,7 @@ PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS_ROUTER* a
ent.clearance = clearance;
m_clearanceCache[i] = ent;
TRACE( 1, "Add net %d netclass %s clearance %d", i % netClassName.mb_str() %
clearance );
wxLogTrace( "PNS", "Add net %d netclass %s clearance %d", i, netClassName.mb_str(), clearance );
}
m_overrideEnabled = false;
@ -467,7 +466,7 @@ PNS_ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
break;
default:
TRACE( 0, "unsupported pad type 0x%x", aPad->GetAttribute() );
wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
return NULL;
}
@ -562,7 +561,7 @@ PNS_ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
break;
default:
TRACEn( 0, "unsupported pad shape" );
wxLogTrace( "PNS", "unsupported pad shape" );
delete solid;
return NULL;
}
@ -659,7 +658,7 @@ PNS_ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
}
default:
TRACEn( 0, "unsupported pad shape" );
wxLogTrace( "PNS", "unsupported pad shape" );
delete solid;
return NULL;
@ -703,7 +702,7 @@ PNS_ITEM* PNS_KICAD_IFACE::syncVia( VIA* aVia )
void PNS_KICAD_IFACE::SetBoard( BOARD* aBoard )
{
m_board = aBoard;
TRACE( 1, "m_board = %p\n", m_board );
wxLogTrace( "PNS", "m_board = %p\n", m_board );
}
@ -711,7 +710,7 @@ void PNS_KICAD_IFACE::SyncWorld( PNS_NODE *aWorld )
{
if( !m_board )
{
TRACEn( 0, "No board attached, aborting sync." );
wxLogTrace( "PNS", "No board attached, aborting sync." );
return;
}

View File

@ -345,7 +345,7 @@ void PNS_LINE::ShowLinks()
return;
}
wxLogTrace( "PNS", "line %p: %d linked segs\n", this, (int) m_segmentRefs->size() );
wxLogTrace( "PNS", "line %p: %lu linked segs\n", this, (int) m_segmentRefs->size() );
for( int i = 0; i < (int) m_segmentRefs->size(); i++ )
wxLogTrace( "PNS", "seg %d: %p\n", i, (*m_segmentRefs)[i] );

View File

@ -20,8 +20,6 @@
#include <boost/optional.hpp>
#include "trace.h"
#include "pns_node.h"
#include "pns_line_placer.h"
#include "pns_walkaround.h"
@ -195,8 +193,8 @@ bool PNS_LINE_PLACER::handlePullback()
m_direction = DIRECTION_45( last );
m_p_start = last.A;
TRACE( 0, "Placer: pullback triggered [%d] [%s %s]",
n % last_tail.Format().c_str() % first_head.Format().c_str() );
wxLogTrace( "PNS", "Placer: pullback triggered [%d] [%s %s]",
n, last_tail.Format().c_str(), first_head.Format().c_str() );
// erase the last point in the tail, hoping that the next iteration will
// result with a head trace that starts with a segment following our
@ -261,7 +259,7 @@ bool PNS_LINE_PLACER::reduceTail( const VECTOR2I& aEnd )
if( reduce_index >= 0 )
{
TRACE( 0, "Placer: reducing tail: %d", reduce_index );
wxLogTrace( "PNS", "Placer: reducing tail: %d", reduce_index );
SHAPE_LINE_CHAIN reducedLine = new_direction.BuildInitialTrace( new_start, aEnd );
m_p_start = new_start;
@ -304,13 +302,13 @@ bool PNS_LINE_PLACER::mergeHead()
if( n_head < 3 )
{
TRACEn( 4, "Merge failed: not enough head segs." );
wxLogTrace( "PNS", "Merge failed: not enough head segs." );
return false;
}
if( n_tail && head.CPoint( 0 ) != tail.CPoint( -1 ) )
{
TRACEn( 4, "Merge failed: head and tail discontinuous." );
wxLogTrace( "PNS", "Merge failed: head and tail discontinuous." );
return false;
}
@ -346,7 +344,7 @@ bool PNS_LINE_PLACER::mergeHead()
head.Remove( 0, n_head - 2 );
TRACE( 0, "Placer: merge %d, new direction: %s", n_head % m_direction.Format().c_str() );
wxLogTrace( "PNS", "Placer: merge %d, new direction: %s", n_head, m_direction.Format().c_str() );
head.Simplify();
tail.Simplify();
@ -574,7 +572,7 @@ bool PNS_LINE_PLACER::optimizeTailHeadTransition()
{
PNS_LINE tmp( m_tail, opt_line );
TRACE( 0, "Placer: optimize tail-head [%d]", threshold );
wxLogTrace( "PNS", "Placer: optimize tail-head [%d]", threshold );
head.Clear();
tail.Replace( -threshold, -1, new_head.CLine() );
@ -599,9 +597,8 @@ void PNS_LINE_PLACER::routeStep( const VECTOR2I& aP )
PNS_LINE new_head;
TRACE( 2, "INIT-DIR: %s head: %d, tail: %d segs\n",
m_initial_direction.Format().c_str() % m_head.SegmentCount() %
m_tail.SegmentCount() );
wxLogTrace( "PNS", "INIT-DIR: %s head: %d, tail: %d segs\n",
m_initial_direction.Format().c_str(), m_head.SegmentCount(), m_tail.SegmentCount() );
for( i = 0; i < n_iter; i++ )
{
@ -789,8 +786,8 @@ void PNS_LINE_PLACER::initPlacement()
setWorld( rootNode );
TRACE( 1, "world %p, intitial-direction %s layer %d\n",
m_world % m_direction.Format().c_str() % aLayer );
wxLogTrace( "PNS", "world %p, intitial-direction %s layer %d\n",
m_world, m_direction.Format().c_str(), m_currentLayer );
m_lastNode = NULL;
m_currentNode = m_world;
@ -977,7 +974,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE& aLatest )
}
}
TRACE( 0, "total segs removed: %d/%d\n", removedCount % total );
wxLogTrace( "PNS", "total segs removed: %d/%d\n", removedCount, total );
}
for( PNS_SEGMENT *s : toErase )

View File

@ -20,8 +20,6 @@
#include <base_units.h> // God forgive me doing this...
#include "trace.h"
#include "pns_node.h"
#include "pns_itemset.h"
#include "pns_topology.h"

View File

@ -20,8 +20,6 @@
#include <base_units.h> // God forgive me doing this...
#include "trace.h"
#include "pns_node.h"
#include "pns_itemset.h"
#include "pns_topology.h"

View File

@ -20,8 +20,6 @@
#include <base_units.h> // God forgive me doing this...
#include "trace.h"
#include "pns_node.h"
#include "pns_itemset.h"
#include "pns_topology.h"

View File

@ -28,7 +28,6 @@
#include <geometry/shape_line_chain.h>
#include <geometry/shape_index.h>
#include "trace.h"
#include "pns_item.h"
#include "pns_line.h"
#include "pns_node.h"
@ -47,7 +46,7 @@ static boost::unordered_set<PNS_NODE*> allocNodes;
PNS_NODE::PNS_NODE()
{
TRACE( 0, "PNS_NODE::create %p", this );
wxLogTrace( "PNS", "PNS_NODE::create %p", this );
m_depth = 0;
m_root = this;
m_parent = NULL;
@ -63,18 +62,18 @@ PNS_NODE::PNS_NODE()
PNS_NODE::~PNS_NODE()
{
TRACE( 0, "PNS_NODE::delete %p", this );
wxLogTrace( "PNS", "PNS_NODE::delete %p", this );
if( !m_children.empty() )
{
TRACEn( 0, "attempting to free a node that has kids.\n" );
wxLogTrace( "PNS", "attempting to free a node that has kids.\n" );
assert( false );
}
#ifdef DEBUG
if( allocNodes.find( this ) == allocNodes.end() )
{
TRACEn( 0, "attempting to free an already-free'd node.\n" );
wxLogTrace( "PNS", "attempting to free an already-free'd node.\n" );
assert( false );
}
@ -108,7 +107,7 @@ PNS_NODE* PNS_NODE::Branch()
{
PNS_NODE* child = new PNS_NODE;
TRACE( 0, "PNS_NODE::branch %p (parent %p)", child % this );
wxLogTrace( "PNS", "PNS_NODE::branch %p (parent %p)", child, this );
m_children.insert( child );
@ -131,8 +130,8 @@ PNS_NODE* PNS_NODE::Branch()
child->m_override = m_override;
}
TRACE( 2, "%d items, %d joints, %d overrides",
child->m_index->Size() % child->m_joints.size() % child->m_override.size() );
wxLogTrace( "PNS", "%d items, %lu joints, %lu overrides",
child->m_index->Size(), child->m_joints.size(), child->m_override.size() );
return child;
}
@ -583,7 +582,7 @@ void PNS_NODE::addSegment( PNS_SEGMENT* aSeg, bool aAllowRedundant )
{
if( aSeg->Seg().A == aSeg->Seg().B )
{
TRACEn( 0, "attempting to add a segment with same end coordinates, ignoring." )
wxLogTrace( "PNS", "attempting to add a segment with same end coordinates, ignoring." );
return;
}

View File

@ -33,7 +33,6 @@
#include <geometry/shape_rect.h>
#include <geometry/shape_circle.h>
#include "trace.h"
#include "pns_node.h"
#include "pns_line_placer.h"
#include "pns_line.h"

View File

@ -23,7 +23,6 @@
#include <deque>
#include <cassert>
#include "trace.h"
#include "range.h"
#include "pns_line.h"
@ -191,19 +190,19 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE& aCurrent, PNS_LINE&
if( ( vFirst < 0 || vLast < 0 ) && !path.CompareGeometry( aObstacle.CLine() ) )
{
TRACE( 100, "attempt %d fail vfirst-last", attempt );
wxLogTrace( "PNS", "attempt %d fail vfirst-last", attempt );
continue;
}
if( path.CPoint( -1 ) != obs.CPoint( -1 ) || path.CPoint( 0 ) != obs.CPoint( 0 ) )
{
TRACE( 100, "attempt %d fail vend-start\n", attempt );
wxLogTrace( "PNS", "attempt %d fail vend-start\n", attempt );
continue;
}
if( !checkBumpDirection( aCurrent, l ) )
{
TRACE( 100, "attempt %d fail direction-check", attempt );
wxLogTrace( "PNS", "attempt %d fail direction-check", attempt );
aShoved.SetShape( l.CLine() );
continue;
@ -211,7 +210,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE& aCurrent, PNS_LINE&
if( path.SelfIntersecting() )
{
TRACE( 100, "attempt %d fail self-intersect", attempt );
wxLogTrace( "PNS", "attempt %d fail self-intersect", attempt );
continue;
}
@ -230,7 +229,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE& aCurrent, PNS_LINE&
if( colliding )
{
TRACE( 100, "attempt %d fail coll-check", attempt );
wxLogTrace( "PNS", "attempt %d fail coll-check", attempt );
continue;
}
@ -587,7 +586,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
if( !jt )
{
TRACEn( 1, "weird, can't find the center-of-via joint\n" );
wxLogTrace( "PNS", "weird, can't find the center-of-via joint\n" );
return SH_INCOMPLETE;
}
@ -949,7 +948,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
case PNS_ITEM::VIA:
{
PNS_VIA* revVia = (PNS_VIA*) ni;
TRACE( 2, "iter %d: reverse-collide-via", aIter );
wxLogTrace( "PNS", "iter %d: reverse-collide-via", aIter );
if( currentLine.EndsWithVia() && m_currentNode->CheckColliding( &currentLine.Via(), revVia ) )
{
@ -966,7 +965,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
case PNS_ITEM::SEGMENT:
{
PNS_SEGMENT* seg = (PNS_SEGMENT*) ni;
TRACE( 2, "iter %d: reverse-collide-segment ", aIter );
wxLogTrace( "PNS", "iter %d: reverse-collide-segment ", aIter );
PNS_LINE revLine = assembleLine( seg );
popLine();
@ -986,7 +985,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
switch( ni->Kind() )
{
case PNS_ITEM::SEGMENT:
TRACE( 2, "iter %d: collide-segment ", aIter );
wxLogTrace( "PNS", "iter %d: collide-segment ", aIter );
st = onCollidingSegment( currentLine, (PNS_SEGMENT*) ni );
@ -997,7 +996,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
break;
case PNS_ITEM::VIA:
TRACE( 2, "iter %d: shove-via ", aIter );
wxLogTrace( "PNS", "iter %d: shove-via ", aIter );
st = onCollidingVia( &currentLine, (PNS_VIA*) ni );
if( st == SH_TRY_WALK )
@ -1007,7 +1006,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
break;
case PNS_ITEM::SOLID:
TRACE( 2, "iter %d: walk-solid ", aIter );
wxLogTrace( "PNS", "iter %d: walk-solid ", aIter );
st = onCollidingSolid( currentLine, (PNS_SOLID*) ni );
break;
@ -1026,7 +1025,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveMainLoop()
m_affectedAreaSum = OPT_BOX2I();
TRACE( 1, "ShoveStart [root: %d jts, current: %d jts]", m_root->JointCount() %
wxLogTrace( "PNS", "ShoveStart [root: %d jts, current: %d jts]", m_root->JointCount(),
m_currentNode->JointCount() );
int iterLimit = Settings().ShoveIterationLimit();
@ -1144,8 +1143,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
m_currentNode->RemoveByMarker( MK_HEAD );
TRACE( 1, "Shove status : %s after %d iterations",
( ( st == SH_OK || st == SH_HEAD_MODIFIED ) ? "OK" : "FAILURE") % m_iter );
wxLogTrace( "PNS", "Shove status : %s after %d iterations",
( ( st == SH_OK || st == SH_HEAD_MODIFIED ) ? "OK" : "FAILURE"), m_iter );
if( st == SH_OK || st == SH_HEAD_MODIFIED )
{
@ -1241,8 +1240,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet
m_currentNode->RemoveByMarker( MK_HEAD );
TRACE( 1, "Shove status : %s after %d iterations",
( st == SH_OK ? "OK" : "FAILURE") % m_iter );
wxLogTrace( "PNS", "Shove status : %s after %d iterations",
( st == SH_OK ? "OK" : "FAILURE"), m_iter );
if( st == SH_OK )
{
@ -1290,7 +1289,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR
{
if( aNewVia )
{
wxLogTrace( "PNS","setNewV %p", m_draggedVia);
wxLogTrace( "PNS","setNewV %p", m_draggedVia );
*aNewVia = m_draggedVia;
}

View File

@ -55,8 +55,6 @@ using namespace std::placeholders;
#include "pns_tune_status_popup.h"
#include "pns_topology.h"
#include "trace.h"
using namespace KIGFX;
TOOL_ACTION PNS_TOOL_BASE::ACT_RouterOptions( "pcbnew.InteractiveRouter.RouterOptions",
@ -185,7 +183,9 @@ PNS_ITEM* PNS_TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int a
rv = NULL;
if( rv )
TRACE( 0, "%s, layer : %d, tl: %d", rv->KindStr().c_str() % rv->Layers().Start() % tl );
{
wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
}
return rv;
}
@ -307,7 +307,9 @@ void PNS_TOOL_BASE::updateEndItem( TOOL_EVENT& aEvent )
}
if( m_endItem )
TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() );
{
wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
}
}

View File

@ -54,7 +54,6 @@ using namespace std::placeholders;
#include "router_tool.h"
#include "pns_segment.h"
#include "pns_router.h"
#include "trace.h"
using namespace KIGFX;
using boost::optional;
@ -296,7 +295,7 @@ void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
switch( aEvent.KeyCode() )
{
case '0':
TRACEn( 2, "saving drag/route log...\n" );
wxLogTrace( "PNS", "saving drag/route log...\n" );
m_router->DumpLog();
break;
}

View File

@ -1,46 +0,0 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013 CERN
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) 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 General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TRACE_H
#define __TRACE_H
#include <string>
#include <iostream>
#include <boost/format.hpp>
static inline void _trace_print( const char* aFuncName, int aLevel, const std::string& aMsg )
{
#ifdef DEBUG
std::cerr << "trace[" << aLevel << "]: " << aFuncName << ": " << aMsg << std::endl;
#endif
}
#ifdef PNS_DEBUG
#define TRACE( level, fmt, ... ) \
_trace_print( __FUNCTION__, level, ( boost::format( fmt ) % __VA_ARGS__ ).str() );
#define TRACEn( level, msg ) \
_trace_print( __FUNCTION__, level, std::string( msg ) );
#else
#define TRACE( ... )
#define TRACEn( ... )
#endif
#endif