You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 CERN
  5. * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Maciej Suminski <maciej.suminski@cern.ch>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 3
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * https://www.gnu.org/licenses/gpl-3.0.html
  21. * or you may search the http://www.gnu.org website for the version 3 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <wx/intl.h>
  26. #include <lib_logger.h>
  27. LIB_LOGGER::LIB_LOGGER() : m_previousLogger( nullptr ), m_activated( false )
  28. {
  29. }
  30. LIB_LOGGER::~LIB_LOGGER()
  31. {
  32. Deactivate();
  33. }
  34. void LIB_LOGGER::Activate()
  35. {
  36. if( !m_activated )
  37. {
  38. m_previousLogger = wxLog::GetActiveTarget();
  39. wxLog::SetActiveTarget( this );
  40. m_activated = true;
  41. }
  42. }
  43. void LIB_LOGGER::Deactivate()
  44. {
  45. if( m_activated )
  46. {
  47. Flush();
  48. m_activated = false;
  49. wxLog::SetActiveTarget( m_previousLogger );
  50. }
  51. }
  52. void LIB_LOGGER::Flush()
  53. {
  54. if( m_bHasMessages )
  55. {
  56. wxLogMessage( _( "Not all symbol libraries could be loaded. Use the Manage Symbol\n"
  57. "Libraries dialog to adjust paths and add or remove libraries." ) );
  58. wxLogGui::Flush();
  59. }
  60. }