2014-05-14 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-05-14 13:53:54 +00:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pns_logger.h"
|
|
|
|
#include "pns_item.h"
|
|
|
|
#include "pns_via.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LOGGER::LOGGER( )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LOGGER::~LOGGER()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void LOGGER::Clear()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
m_events.clear();
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
void LOGGER::Save( const std::string& aFilename )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
FILE* f = fopen( aFilename.c_str(), "wb" );
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
for( const auto evt : m_events )
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
uint64_t id = 0;
|
|
|
|
if( evt.item && evt.item->Parent() )
|
|
|
|
{
|
|
|
|
const char* idString = evt.item->Parent()->m_Uuid.AsString().c_str();
|
|
|
|
fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y, idString );
|
|
|
|
}
|
2015-10-05 16:28:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
fclose( f );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
void LOGGER::Log( LOGGER::EVENT_TYPE evt, VECTOR2I pos, const ITEM* item )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
LOGGER::EVENT_ENTRY ent;
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
ent.type = evt;
|
|
|
|
ent.p = pos;
|
|
|
|
ent.item = item;
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
m_events.push_back( ent );
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
|
|
|
}
|