1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 CERN
5  * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "pns_logger.h"
23 #include "pns_item.h"
24 #include "pns_via.h"
25 
26 #include <wx/log.h>
27 
28 namespace PNS {
29 
LOGGER()30 LOGGER::LOGGER( )
31 {
32 }
33 
34 
~LOGGER()35 LOGGER::~LOGGER()
36 {
37 }
38 
39 
Clear()40 void LOGGER::Clear()
41 {
42     m_events.clear();
43 }
44 
45 
Save(const std::string & aFilename)46 void LOGGER::Save( const std::string& aFilename )
47 {
48     FILE* f = fopen( aFilename.c_str(), "wb" );
49 
50     wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
51 
52     for( const EVENT_ENTRY& evt : m_events )
53     {
54         uint64_t id = 0;
55 
56         fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y,
57                  (const char*) evt.uuid.c_str() );
58     }
59 
60     fclose( f );
61 }
62 
63 
Log(LOGGER::EVENT_TYPE evt,const VECTOR2I & pos,const ITEM * item)64 void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item )
65 {
66     LOGGER::EVENT_ENTRY ent;
67 
68     ent.type = evt;
69     ent.p = pos;
70     ent.uuid = "null";
71 
72 
73     if( item && item->Parent() )
74         ent.uuid = item->Parent()->m_Uuid.AsString();
75 
76     m_events.push_back( ent );
77 }
78 
79 }
80